2017-02-26 7 views
1

に刻み、それはx軸の目盛りが正しく表示this、次のようになります。冗長性の悪いログは、私はmatplotlibのグラフをプロットmatplotlibの

import matplotlib 
import matplotlib.pyplot as plt 
fig1, ax1 = plt.subplots() 
ax1.plot([1, 2, 3], [1,2,3]) 
ax1.set_xscale('log') 
plt.xlim(1,100) 
ax1.set_xticks([1,2,3,4,5,6,7,8,9,10]) 
ax1.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter()) 
plt.show() 
:ここ

は私のコードです

その後、私はここで、x軸の範囲、 plt.xlim(1,10)新しいコードで調整:

import matplotlib 
import matplotlib.pyplot as plt 
fig1, ax1 = plt.subplots() 
ax1.plot([1, 2, 3], [1,2,3]) 
ax1.set_xscale('log') 
plt.xlim(1,10) 
ax1.set_xticks([1,2,3,4,5,6,7,8,9,10]) 
ax1.get_xaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter()) 
plt.show() 

そして今、私は必要としない、いくつかの間違った数字があります。

は、どのように私は小さなx軸の制限などの最初のグラフを達成することができますか?

答えて

0

matplotlib 2+に更新したときに同じ問題が発生しました。私は解決策をthis threadに見つけました。問題は、次のコマンドで削除できる小さな目盛りのようです:

plt.gca().xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter()) 
関連する問題