我正在绘制带有一些重叠点的简单线图,但是出于任何原因,我都可以将xlim设置得很好,但是设置ylim无效,ybound也无效。我尝试将代码行放在块的末尾以及各个位置,但这没有任何作用。谁能帮我弄清楚为什么我的情节似乎忽略了这个命令?代码如下:
fig, ax = plt.subplots()
ax.plot(endpt,exceedperc,'-')
ax.set_title(ttl)
ax.set_xlabel(xlbl + spc + xunit)
ax.set_ylabel(ylbl + spc + yunit)
ax.yaxis.set_major_formatter(mtick.PercentFormatter(max(exceedperc)))
ax.yaxis.set_major_locator(mtick.MultipleLocator(0.1))
ax.grid()
ax.set_xlim(0,np.ceil(max(binlogi)))
ax.set_ylim(0,1)
# Text annotations at 1%, 5%, 10%, 25%, and 50% exceedances
ax.plot([x1[0],x5[0],x10[0],x25[0],x50[0]],[(1/100),(5/100),(10/100),(25/100),(50/100)],linestyle='None',marker='o',color='r')
ax.annotate(str(x1[0]) + spc + xunit, xy=(x1[0],(1/100)), xycoords='data', xytext=(4,4), textcoords='offset points')
ax.annotate(str(x5[0]) + spc + xunit,xy=(x5[0],(5/100)), xycoords='data', xytext=(4,4), textcoords='offset points')
ax.annotate(str(x10[0]) + spc + xunit,xy=(x10[0],(10/100)), xycoords='data', xytext=(4,4), textcoords='offset points')
ax.annotate(str(x25[0]) + spc + xunit,xy=(x25[0],(25/100)), xycoords='data', xytext=(4,4), textcoords='offset points')
ax.annotate(str(x50[0]) + spc + xunit,xy=(x50[0],(50/100)), xycoords='data', xytext=(4,4), textcoords='offset points')
我期望y轴在0.1个刻度之间限制在0到1之间,但事实并非如此。我得到的结果是从0到1.04的y限制,并且以随机间隔滴答