2013-12-30から1日間の記事一覧

Graphvis 使用例 その2

以下の内容で、sample.dot を作成 graph { 1 -- 6; 1 -- 12; 1 -- 15; 1 -- 16; 2 -- 3; 2 -- 8; 2 -- 10; 3 -- 4; 3 -- 6; 3 -- 9; 5 -- 6; 7 -- 15; 11 -- 16; 13 -- 15; 14 -- 15; } 以下のコマンドを入力 $ dot -Tpng sample.dot -o sample.png 画像 sam…

Graphvis 使用例

以下の内容で、sample.dot を作成 digraph { rankdir=LR; 0 [ shape = doublecircle, label = "0 \n generate=5" ]; 1 [ shape = doublecircle, label = "1 \n generate=2" ]; 3 [ shape = rect, label = "3 \n consume=2" ]; 4 [ shape = rect, label = "4 …

Graphviz インストール手順

Graphvis を使えば、データ構造としてのグラフの可視化を簡単に行える。まずはインストールするための手順をメモ。(※自分の環境: Windows7, Cygwin (8.15-1)) http://www.graphviz.org/Download_windows.php より、graphviz-2.34.msi をダウンロード graphvi…

matplotlibで等高線を書く その2

schwefel.png: CS = ax.contour(x, y, z, ) 等高線図をプロット ax.clabel(CS) 各等高線に値を記入 contour関数のオプション (一部) cmap: カラーマップ clabel関数のオプション (一部) fontsize: フォントの大きさ inline: True なら、値の周りの等高線を消…

matplotlibで等高線図を書く

schwefel.png: ax.contour(x, y, z, zdir=, offset=) contour関数のオプション(一部) zdir: どの平面に投射するか(x, y, zのいずれか) offset: 平面のどの位置に描画するか cmap: カラーマップ #!/usr/bin/env python #coding:utf-8 from mpl_toolkits.mplot…

matplotlibでサーファイスプロットする

schwefel.png: surf = ax.plot_surface(x, y, z) 三次元プロット fig.colorbar(surf) カラーバーの表示 plot_surface関数のキーワード(一部) cmap: カラーマップの指定 (hot, gray, coolwarm など) cstride: x方向の色のプロットのステップ数(デフォルト値: …

numpy で3変数の回帰分析

polyfit.png: np.polyfit(x, zip(y,z), n) n次式で3変数の回帰分析 3Dデータのプロット ax = fig.add_subplot(1, 1, 1, projection="3d", azim=) ax.plot(x,y,z) azim に値を代入して視点を変える #!/usr/bin/env python #coding:utf-8 from mpl_toolkits.mp…

numpy で2変数の回帰分析

polyfit.png: np.polyfit(x, y, n) n次式で2変数の回帰分析 np.polyval(p, t): pで表される多項式に t を代入し、値を計算して返す p[0]*t**(N-1) + p[1]*t**(N-2) + ... + p[N-2]*t + p[N-1] #!/usr/bin/env python #coding: utf-8 import matplotlib.pyplo…