http://matplotlib.org/examples/pylab_examples/hatch_demo.html
http://codepad.org/pK6n6ZRY
http://imagingsolution.blog107.fc2.com/blog-entry-193.html
ごり押しだがなんとかなった。二値化画像imgがあるとすると、
label_img, nb_labels = ndimage.label(img) num = np.histogram(label_img, nb_labels) num = num[0] num = num[1:] num.sort() num[num>4]
などで取得できる。最後は、5画素以上の場合のみを取得している。
http://d.hatena.ne.jp/sle/20080615/1213497687
from __future__ import division
cmap = cm.get_cmap('rainbow', 10)
など。
http://stackoverflow.com/questions/12570627/getting-a-matplotlib-colorbar-tick-outside-data-limits-for-use-with-boundaries-k
ついでにカラー一覧
http://www.physics.ox.ac.uk/users/msshin/science/code/matplotlib_cm/
ついでにカラーバーの表示
fig.colorbar(graph, shrink=0.6) #cbar.ax.set_yticklabels(np.linspace(zmin, zmax, 11))
http://matplotlib.org/users/text_intro.html
http://stackoverflow.com/questions/12750355/python-matplotlib-figure-title-overlaps-axes-label-when-using-twiny
など。
https://support.enthought.com/entries/23580651-Uninstalling-Canopy
ここが詳しい。重要なのは、canopyをpythonのデフォルトにしないことだ。または、レジストリのpythonのpathを削除しておく。これをせずにpythonxyをインストールすると、pathがぐちゃぐちゃになってまったく起動しないという事態に陥った。
Python(x,y)
https://code.google.com/p/pythonxy/wiki/Downloads
が一番楽そう。
http://aikotobaha.blogspot.jp/2011/12/python-idle.html
Options > Configure IDLE > Highlighting
からも出来る
Python
C:\Python27
OpenCV
C:\opencv\248\opencv\build\x86\vc10\bin
C:\OpenCV2.3\build\Python\2.7\Lib\site-packages
などにあるcv2.pydを
C:\Python27\Lib\site-packages
などにコピーする
import glob filenames = glob.glob("test/*.*")
#全データ読み込み imgs = [np.loadtxt(filename, delimiter="\n") for filename in filenames] #numpy.array行列に変換 imgs = np.array(imgs) #ファイル数 x 画素数の行列に変換 imgs = imgs.reshape((len(filenames),-1))
imgs = np.array([np.loadtxt(filename, delimiter="\n") for filename in filenames])[:,:10000]
mean_img = imgs.mean(axis=0)
import numpy as np np.savetxt("a.txt", img)
import natplotlib.pyplot as plt plt.plot(img) #グリッド作成 plt.grid() #ticks yrange = [-0.006, -0.0062, -0.0064, -0.0066, -0.0068, -0.0070] yrangen = ("-6.0","-6.2","-6.4","-6.6","-6.8","-7.0") plt.yticks(yrange, yrangen) #y軸の表示範囲 plt.ylim(ymin,ymax) plt.xlabel(u"ああ", fontsize=20, fontname='sans-serif') plt.title(u"ああ", fontsize=20, fontname='sans-serif') plt.savefig("a.png") plt.clf()
#y軸の範囲 ystart = -0.5 yend = 0.5 yrange = np.linspace(ystart, yend, 11) #y軸に表示する文字列 yscale = 1 yrangen = yrange * yscale yrangen = map(round,list(yrangen)) yrangen = map(int,list(yrangen)) yrangen = tuple(map(str,yrangen)) plt.yticks(yrange, yrangen) plt.ylim(ystart,yend)
import cv2 cv2.imwrite("a.png", img)
#行 img[0,:] #列 img[:,0]
#行 img.mean(axis=0) #列 img.mean(axis=1)
http://plog.web-hack.org/2011/01/matplotlib.html
日本語フォントが
c:\Windows\Fonts c:\Python27\Lib\site-packages\matplotlib\mpl-data\fonts\ttf
になければいけない。
c:\Python26\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
の中の
#font.serif ... #font.sans-serif ...
を
font.serif : 日本語フォント名 font.sans-serif : 日本語フォント名
に変更すると楽。
C:\Documents and Settings\Administrator\.matplotlib\fontList.cache
キャッシュも消しておく。
plt.xlabel(u"あああ", fontsize=20, fontname='sans-serif') plt.show()
とかで確認。
実行するとき、ファイルアドレスに日本語表記が含まれているとエラーが出るようだ。
~\デスクトップ\tes.py
など。
簡単に言えば、3Dグラフをどこから見るか調整する。
ax.view_init(elev=100., azim=100)
stepfilledとedgecolorを同じ色にすれば良い
ax.hist(data, bins=200, normed=False, histtype='stepfilled', edgecolor='b', alpha=0.8)