问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider
x = range(1000)
y = range(1000)
fig,ax = plt.subplots()
ax.plot(x,y,'b')
showbars = 200
def slidebar(pos):
ax.set_xlim(pos - 1, pos + showbars + 1)
plt.grid(alpha=0.4)
slidebarpos = plt.axes([0.2, 0.01, 0.5, 0.03], facecolor="skyblue")
slider = Slider(slidebarpos, '', 0, len(x) - showbars, valinit=0)
slider.on_changed(slidebar)
slidebar(0)
plt.show()
运行结果及报错内容

我的解答思路和尝试过的方法
我想要达到的结果
目前的情况是运行后,Y轴的刻度不会自动适应图表,如何改成Y轴刻度随着 SLIDER 滚动条滚动而改变

