Сюжет, который я хочу скопировать

Код: Выделить всё
# Plot of the line I want to add
def transition_line(xmin, xmax):
for i in range((df_irv['Distance'] - xmin).abs().idxmin(), (df_irv['Distance'] - xmax).abs().idxmin()):
plt.plot([df_irv['Distance'][i], df_irv['Distance'][i+1]], [max(df_irv['SuspTravel']) + 0.5]*2, color='red' if df_irv['Element'][i] == 'CURVA' else 'blue', linewidth=10, alpha=0.5)
# Function to plot the data with adjustable x-axis limits
def plot_graph(xmin, xmax, sensors):
plt.figure(figsize=(10, 5))
plt.plot(df_irv['Distance'], df_irv[sensors], label='Suspension Sensor')
plt.xlim(xmin, xmax)
plt.xlabel('Distance (Km)')
plt.ylabel('Suspension Sensor')
plt.title('Suspension Sensor vs Distance')
plt.legend()
plt.grid(True)
transition_line(xmin, xmax)
plt.show()
# Create sliders for x-axis limits
xmin_slider = IntSlider(value=0, min=0, max=df_irv['Distance'].max(), step=1, description='X min')
xmax_slider = IntSlider(value=20, min=0, max=df_irv['Distance'].max(), step=1, description='X max')
# Interactive plot
interact(plot_graph, xmin=xmin_slider, xmax=xmax_slider, sensors = ['SuspTravel', 'Roll', 'Bounce'])
[img]https://i .sstatic.net/fzRlgKA6.png[/img]
Подробнее здесь: https://stackoverflow.com/questions/785 ... -something