2017-08-18 8 views
0

何らかの理由で、plt.autoscaleが非常に小さい値(1E-05など)で動作しないようです。図のように、すべてがグラフのゼロ軸の近くに表示されます。小さい値の場合、Matplotlibのオートスケールがy軸で機能しないようですか?

私はここで間違っていますか?

import matplotlib.pyplot as plt 

y= [1.09E-05, 1.63E-05, 2.45E-05, 3.59E-05, 5.09E-05, 6.93E-05, 9.07E-05] 
x= [0, 10, 20, 30, 40, 50, 60] 

fig3, ax3 = plt.subplots() 
ax3.scatter(x, y, color='k', marker = "o") 
ax3 = plt.gca() 
plt.autoscale(enable=True, axis="y", tight=False) 
plt.show() 

enter image description here

答えて

1

私はこれはまだmatplotlibの中で解決されていないa known issueであると信じています。 hereまたはhereと同じです。この場合の

可能な解決策は

使用plotの代わりscatterだろう。

import matplotlib.pyplot as plt 

y= [1.09E-05, 1.63E-05, 2.45E-05, 3.59E-05, 5.09E-05, 6.93E-05, 9.07E-05] 
x= [0, 10, 20, 30, 40, 50, 60] 

fig3, ax3 = plt.subplots() 
ax3.plot(x, y, color='k', marker = "o", ls="") 
ax3.autoscale(enable=True, axis="y", tight=False) 
plt.show() 

見えないplot使用scatter

import matplotlib.pyplot as plt 

y= [1.09E-05, 1.63E-05, 2.45E-05, 3.59E-05, 5.09E-05, 6.93E-05, 9.07E-05] 
x= [0, 10, 20, 30, 40, 50, 60] 

fig3, ax3 = plt.subplots() 
ax3.scatter(x, y, color='k', marker = "o") 
ax3.plot(x, y, color='none') 
ax3.relim() 
ax3.autoscale_view() 
plt.show() 

に加えて、手動でset_ylimを使用して軸を拡大。

import matplotlib.pyplot as plt 

y= [1.09E-05, 1.63E-05, 2.45E-05, 3.59E-05, 5.09E-05, 6.93E-05, 9.07E-05] 
x= [0, 10, 20, 30, 40, 50, 60] 

fig3, ax3 = plt.subplots() 
ax3.scatter(x, y, color='k', marker = "o") 

dy = (max(y) - min(y))*0.1 
ax3.set_ylim(min(y)-dy, max(y)+dy) 
plt.show() 
+0

これは既に以前に尋ねられました。それでも有益な答えを提供していただきありがとうございます! – bwrr

関連する問題