[英]Is there a way to set the limits on the y axis in python (Matplotlib)?
我是 Python (v 3.7) 的新手,目前正在處理學生數據。 我正在使用以下代碼:
x = np.arange(timepoints.shape[0])/sample_rate
f = pl.figure(figsize = (10,3.5))
pl.plot(x, pupil)
pl.xlabel('Time (s)')
pl.ylabel('Pupil size')
sn.despine(offset=10)
使用上面的代碼,我收到以下 output:
我希望 y 軸限制在 0-1000 的范圍內。 我已經嘗試過ylim
,但這似乎不起作用,我仍然收到相同的 output。
這是帶有以下代碼的新圖:
x = np.arange(timepoints.shape[0]) / sample_rate
f = pl.figure(figsize = (15,3.5))
pl.plot(x, pupil)
pl.yticks(np.linspace(0, 1000, 10))
pl.xlabel('Time (s)')
pl.ylabel('Pupil size (a.u)')
sn.despine(offset=10)
我試過玩弄數字等,但它似乎仍然不合作。
如果你之前用谷歌搜索過,那就更好了。 有一種方法可以做到
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.ylim.html
一探究竟!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.