1

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).

Green curve is derived using cubic spline from blue curve, and projected onto the same grid as yellow.

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).

Hojin Cho
  • 384
  • 2
  • 12
  • This post seems useful: [Reduce number of points in line](https://stackoverflow.com/questions/2573997/reduce-number-of-points-in-line) – JohanC Jun 06 '20 at 07:43

0 Answers0