I need to draw a plot of a function that I know its analytic form. For example, y=exp(-x^2/2)
.
If I plot this function over an interval of [-5,5]
with 11 points, I get the blue curve below. Notice how lines connecting points are linearly interpolated, making an incorrect representation of the function. If I use more points, I could get more accurate plot like the yellow curve below. On the other hand, if I use cubic spline then the curve seems more realistic even if the sampling rate is low (green curve).
This is not a problem in most cases, but if I want a vector output like svg
or pdf
, I'd love to reduce the number of points as low as possible to minimize the size of output. So, I'd like to see if there is any option in matplotlib
or any other python
-based plotting library that can either connect the dots using spline, or specify the slope and curvature at each point (similar to Photoshop or MS Powerpoint).