This question is half programming but also half mathematics. I want to interpolate a set of points by a curve without adding unnecessary extremums staying \"close to the lin
Have you tried a quadratic spline instead - though I am not convinced that will help. Another fudge option is to add additional data-points very close to your maximums. e.g. at (-0.05,4) and (1.95, -6) - this would cause the cubic spline algorithm to flatten those areas near the maximum. Depends what you are trying to achieve. There are techniques to constrain maximum and minimum of cubic splines but I am not familiar enough with those or python / matplotlib to help, sorry!