2013-07-24 16 views
6

matplotlib.pyplotで作成されたプロットでは、軸ラベルを強制的に指数表記で表示できますか?これは値< 1e-6に対して自動的に行われるようですが、例えば5e-6の場合は「0.000005」となります。私はこの範囲でも "5e-6"と表示したいと思っています。Matplotlib.pyplot:指数軸ラベルの表記を強制的に

+0

http://matplotlib.org/api/ticker_api.html#matplotlib.ticker.FormatStrFormatter ' "%eは"'あなたがより良いものを行うと、ちょうどset_powerlimits'に '呼び出すことができます指数 –

答えて

5

は、ScalarFormatterの軸の出力制限を設定できるように、と思われます。 (未テストコード)

# Set limits to x < 10^1 and x > 10^-1 
# (overlapping, thus all inclusive, hopefully) 
gca().get_yaxis().get_major_formatter().set_powerlimits((0, 0)) 
+3

です'gca()。get_major_formatter()' – tacaswell

+0

@tcaswell:いいね、ありがとう。 – voithos

+1

@voithos: 'gca()。yaxis.get_major_formatter()。set_powerlimits(( - 1,1))'を使う必要がありました。一度に両方の軸に変更を適用する(エレガントな)方法はありますか? @tcaswell:どうしますか?引数なしで 'set_powerlimits'を呼び出すと、エラーが発生しました。 – gandi2223

関連する問題