Bonjour à tous,

Je n'arrive pas à obtenir le lissage attendu sur une courbe :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import make_interp_spline, CubicSpline, UnivariateSpline
 
x = (0,3,5,10,30,60,90,120,150,180)
y = (20,890,1140,1200,1300,1350,1300,1200,1200,1200)
 
x_new = np.linspace(min(x), max(x),130)
 
f =  make_interp_spline(x, y)
f1 = CubicSpline(x, y)
f2 =  UnivariateSpline(x, y)
#f2.set_smoothing_factor(0.9)
 
y_smooth=f(x_new)
y1_smooth=f1(x_new)
y2_smooth=f2(x_new)
 
plt.plot(x, y, '--o', label = 'standard')
plt.plot(x_new, y_smooth, '-', label ='spline')
plt.plot(x_new, y1_smooth, '-', label ='spline1')
plt.plot(x_new, y2_smooth, '-', label ='spline2')
plt.legend( loc='best')
plt.show()
Quelles que soient les méthodes employées j'ai un espèce virgule non souhaitée... Avez une idée une solution, je vois pas ou ce que je zappe.


Merci