Created
June 9, 2013 04:42
-
-
Save mkacky/5737684 to your computer and use it in GitHub Desktop.
Test of scientific notation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# 単純に大きな数字が2つならんだデータ | |
data = [980000, 500000] | |
# バーの左端の座標 | |
ind = np.arange(len(data)) | |
# バーの幅 | |
width = 0.5 | |
# 棒グラフをプロット | |
plt.bar(ind, data, width) | |
# X軸に簡単なラベルを設定 | |
plt.xticks(ind+width/2., ["A","B"]) | |
# 左右の余白 | |
margin = 0.25 | |
# 余白を加味したx軸方向の変域 | |
plt.xlim(-margin, ind[-1]+width+margin) | |
# Y軸ラベル | |
plt.ylabel('Y label') | |
# Y軸ラベルが見切れてしまったらここで調整 | |
#plt.gcf().subplots_adjust(left=0.2) | |
# Y軸を指数表記(scientific notation)に変更 | |
plt.gca().ticklabel_format(style="sci", scilimits=(0,0), axis="y") | |
# 画像を保存 | |
plt.savefig("testSci.png") | |
# 確認用描画 | |
#plt.show() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment