gnuplotの使い方
まあグラフ作成ソフトなんていくらでもあるので,
gnuplotを使おうなんて人はいないと思うけど,
あえてgnuplotを使いたい人のためのメモ(c言語で動かせたりして便利だよ).
gnuplotが真価を発揮するのは,Xfigで編集して即TeXに取り込めるところだと思う.
インストール
Windows
gnuplotのhomepageからprevious stable(安定版)を見つける.
gnuplot 5.2.8が現状安定版らしい(2021/1/3).
インストーラ(gp528-win64-mingw.exe)をダウンロードしてインストールする.
普通に読んでクリックしていけば難しくないはず.
インストールしたらコマンドプロンプトを開いて“gnuplot”って打ってみて,
“plot sin(x)“とか打ってみてサインカーブが書けたらインストールできてるよ.
Mac
Macはhomebrewからインストール.
homebrewをインストールしてない場合は,ターミナルから
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
を実行してください.
homebrewがインストールできている場合は,ターミナルから
brew install gnuplot
でインストールできます.
あとはWindowsと同じようにターミナルに”gnuplot”って打ってみて,
“plot sin(x)“とか打ってみてサインカーブが書けたらインストールできてるよ.
目盛り見出し
gnuplotは数字の3桁コンマを出せないっぽい?ので, 目盛り見出しをマニュアルで編集.
set ytics ('50,000' 50000, '10,000' 10000)
#50000の目盛りを任意の文字列50,000に差し替える
ラベル
set xlabel "xjiku" #x軸のラベル set ylabel "yjiku" #y軸のラベル
ちなみに全角でラベルを入れたい場合は
set terminal pdf color font "Meiryo,14" enhanced set xlabel "x軸" font "Meiryo.ttf,16" #Meiryoフォントでサイズ16 set ylabel "y軸" font "Meiryo.ttf,16"
色の参考に
黄色の配色が難しい
黄色系の色で段々薄くなっていく(何ていうのか)タイプのグラフが難しい.
現状ではこんな感じがベストか
16進数カラー値で
E3C700, FFE419, FFED65, FFF399, FEF9CC
3Dグラフ
set terminal pdf color font "Times New Roman,14" enhanced
set label 2 "Lumber and wood products ¥n self-sufficiency ratios (%)" font "Times New Roman,16" at graph 0.6,-0.9
#地域内自給率(%)}' font "Meiryo.ttf,16" at graph 0.6,-0.9
set label 2 rotate by -7
#set label 1 '{木材価格の割増引率(%)}' font "Meiryo.ttf,16" at graph 1.6,-0.9
set label 1 "Forestry ¥n self-sufficiency ratios (%)" font "Times New Roman,16" at graph 1.65,-0.85,0.15
set label 1 rotate by 26
#set label 3 left '{波及効果倍率}' font "Meiryo.ttf,16" at graph -0.1,-0.25
set label 3 left '{Total effect (Thousand yen)}' font "Times New Roman,16" at graph -0.1,-0.28,-0.25
set label 3 rotate by 90
set output "gurahu_rin0_100.pdf"
set key off
#set pm3d
#set noborder 192
set border 63
set zrange[40000:60000]
set yrange[0:100]
set y2range[0:100]
set ztics ('40,000' 40000, '45,000' 45000, '50,000' 50000, '55,000' 55000, '60,000' 60000) #カンマ区切りを無理やり?
#set cbrange[1.2:2.0] #カラーバーの範囲
set format z "%.0f" #z軸に書式f(ふつうの少数表示)を設定,全桁.小数点以下0桁
#set format cb "%g"
set cbrange[40000:60000]
set cbtics 10000
set cbtics 10000 ('40,000' 40000, '50,000' 50000, '60,000' 60000)
#set mcbtics 4
#set cbtics 0.2 #カラーボックスメモリ間隔
#set ztics 0.05 #z軸メモリ間隔
set grid ztics
set hidden3d
#load "greens.pal"
set palette defined(44000"#ffff00",49333"#92ff1e",54666"#008000",60000"#000000")
splot "rin0_100.csv" u 2:1:3 w l pt 6 lc palette
set terminal windows
set output
出典:Tomohumi Huzita, Ryu Noda, Chihiro Kayo: Regional economic impacts from timber check dam construction - A comparison with concrete check dam construction, Forests, Vol.11, No.10, 1073, https://doi.org/10.3390/f11101073, 2020.
set terminal pdf color font "Times New Roman,14" enhanced
#set terminal postscript eps enhanced color font "Ryumin-Light-EUC-H" 14
set label 2 "Lumber and wood products ¥n self-sufficiency ratios (%)" font "Times New Roman,16" at graph 0.6,-0.9
set label 2 rotate by -7
set label 1 "Percentage changes from ¥n the current lumber price (%)" font "Times New Roman,16" at graph 1.65,-0.85,0.15
set label 1 rotate by 26
set label 3 left '{Total effect (Thousand yen)}' font "Times New Roman,16" at graph -0.1,-0.28,-0.25
set label 3 rotate by 90
#set output "gurahu_na1.pdf"
set output "gurahu_ron_w.pdf"
#set terminal windows
set key off
set cbrange[40000:70000]
set cbtics 10000
set cbtics ('40,000' 40000, '50,000' 50000, '60,000' 60000, '70,000' 70000)
#set pm3d
#set noborder 192
set border 63
set zrange[40000:75000]
set ztics ('40,000' 40000, '45,000' 45000, '50,000' 50000, '55,000' 55000, '60,000' 60000, '65,000' 65000, '70,000' 70000, '75,000' 75000)
set yrange[-70:70]
set y2range[-70:70]
set format z "%g"
set format cb "%g"
#set ztics 0.05
set grid ztics
set hidden3d
#load "blues.pal"
set palette defined(40000"#00ffff",50000"#1e90ff",60000"#0000ff",70000"#000000")
splot "ga1.csv" w l pt 6 lc palette, "i.csv" w l lc rgb "purple"
set terminal windows
set output
出典:Tomohumi Huzita, Ryu Noda, Chihiro Kayo: Regional economic impacts from timber check dam construction - A comparison with concrete check dam construction, Forests, Vol.11, No.10, 1073, https://doi.org/10.3390/f11101073, 2020.
