使用鼠标缩放后,轴刻度标签错误

时间:2019-05-15 13:05:25

标签: python-3.x matplotlib zooming

  

我发现当我更改x轴刻度标签的格式时,当放大到图形上的某个区域时,标签的值不正确

# create a simple plot   
x=arange(6e-6,7e-6,100e-9)
y=random.rand(len(x))    
f=plt.figure(1)
plt.plot(x,y)
plt.grid()
f1=plt.figure(1)
plt.plot(x,y)

#Then I change the format of the labels:
x=f.get_axes()[0]
xlabels = [format(label, ',.1f') for label in ax.get_xticks()]
ax.set_xticklabels(xlabels)

#and when I zoom in, the peak is not at the same x-location as before the zoom

before label formatting

after label formatting

when zoomed in

0 个答案:

没有答案
相关问题