良いまとめ
グラフの種類
mathematical expression (incl. Greek charachters)
save PDF (with high resolution)
color
format etc.
label name
plt.xlabel("Features", fontsize=18)
plt.ylabel("Weight", fontsize=18)
plot format
plt.plot(x, y1, color='red', label='Training', linewidth=2.5)
plt.plot(x, y2, color='blue', label='Test', linewidth=2.5)
axis range (min, max)
plt.xlim(xmax=len(Y))
plt.ylim(ymin=-0.5)
rename tick names
tick_lcs = np.array([0, 500, 1000])
tick_lbs = np.array(['13000', '13500', '14000'])
plt.xticks(tick_lcs, tick_lbs)
save pdf
plt.savefig(sys.argv[1]+".pdf", format = 'pdf')
legend
http://matplotlib.org/users/legend_guide.html
http://d.hatena.ne.jp/yosshi71jp/20100426/1272301223
xticksのrotation
plt.setp(plt.xticks()[1], rotation=30)
棒グラフ等で、左右に余白を取る
plt.xlim([min(xdata) - 0.5, max(xdata) + 0.5])
error-bar
plt.errorbar(x, y, yerr=error, fmt='.-')
hierarchical clustering
http://nbviewer.ipython.org/github/herrfz/dataanalysis/blob/master/week3/hierarchical_clustering.ipynb
http://stackoverflow.com/questions/11917779/how-to-plot-and-annotate-hierarchical-clustering-dendrograms-in-scipy-matplotlib
http://docs.scipy.org/doc/scipy/reference/generated/scipy.cluster.hierarchy.dendrogram.html
for loop等で、複数のグラフを出力する時に、pltをクリアする
plt.clf()
http://stackoverflow.com/questions/8213522/when-to-use-cla-clf-or-close-for-clearing-a-plot-in-matplotlib
グラフの枠線オン&オフ
http://qiita.com/irs/items/fe909442be057f0efb48
scatter plot でx軸までの垂線を引きたい場合
stem(x,y)
http://stackoverflow.com/questions/21192576/matplotlib-vertical-lines-in-scatter-plot
transparency
e.g., alpha(0.3)
最終更新:2017年05月12日 22:47