
Contents
実行環境
••
•
•
psql
準備その 1 : Cygwin の bash シェルから Win 版 gnuplot 起動
今日の大枠は「Cygwinいろんなパス記述法がある中、↓ のように「ドライブレター始まりのスラッシュ区切りのフルパス」で
$ d:/works/gnuplot/current/bin/gnuplot G N U P L O T Version 5.0 patchlevel 4 last modified 2016-07-21 Copyright (C) 1986-1993, 1998, 2004, 2007-2016 Thomas Williams, Colin Kelley and many others gnuplot home: http://www.gnuplot.info faq, bugs, etc: type "help FAQ" immediate help: type "help" (plot window: hit 'h') gnuplot changed the codepage of this console from 65001 to 932 to match the graph window. Some characters might only display correctly if you change the font to a non-raster type.Terminal type set to 'wxt' gnuplot>

起動メッセージの最後に
gnuplot> set polar; plot(cos(2 * t)) dummy variable is t for curves (graphic window appears)

Win
$ cygstart d:/works/gnuplot/current/bin/wgnuplot (gnuplot GUI window starts) $

cygstart

なお
準備その 2 : Cygwin 版 psql から Win 版 gnuplot 起動
psql-- set gnuplot path # \setenv wingp 'd:/works/gnuplot/current/bin' # \! $wingp/gnuplot G N U P L O T Version 5.0 patchlevel 4 last modified 2016-07-21 ... Terminal type set to 'wxt' gnuplot> set polar; plot(sin(2 * t)) (graphic window appears) gnuplot> exit #

psql から標準出力で gnuplot にデータを渡す
前回のバッチモードとほぼ同じ構文。psql前回と違うポイントは、gnuplot
前回はクエリ結果の列間区切りをタブにしましたが、半角空白
-- set output format # \t on \\\pset format unaligned \\\f ' ' -- query and plot the 1st and the 2nd columns # select cos(2 * t) * x, cos(2 * t) * y, sin(2 * t) * x, sin(2 * t) * y from cast(generate_series(-1, 1, 0.01) * pi() as float) as t, cast(cos(t) as float) as x, cast(sin(t) as float) as y\g | $wingp/gnuplot -p -e "set nokey; p '-' w lines"

グラフを閉じれば自動的に
# \t off \\\pset format aligned \\\g +------------------------+------------------------+------------------------+------------------------+ | ?column? | ?column? | ?column? | ?column? | +------------------------+------------------------+------------------------+------------------------+ | -1 | -1.22464679914735e-016 | -2.44929359829471e-016 | -2.99951956532372e-032 | | -0.997534262484406 | -0.031348777120193 | -0.0627595361983212 | -0.00197229788132577 | | -0.99015698957848 | -0.0622953975282058 | -0.125085917057519 | -0.00786973884979149 | | -0.977927825140012 | -0.0924413963603575 | -0.186549709678872 | -0.0176341394630685 | | -0.960945593601364 | -0.121395659560187 | -0.246728893124492 | -0.0311691077131134 | | -0.939347432391753 | -0.148778017349658 | -0.305212482389889 | -0.048340908203385 | | -0.913307588115352 | -0.174222740196636 | -0.361604054782361 | -0.0689796626133371 | | -0.883035887157219 | -0.197381906128217 | -0.415525147524759 | -0.0928808747815283 | | -0.848775894275021 | -0.217928609381917 | -0.466618496546772 | -0.11980726685361 | | -0.810802775500298 | -0.235559981795615 | -0.514551087834844 | -0.149490910176645 | | -0.769420884293813 | -0.25 | -0.559016994374948 | -0.18163563200134 | ...
\g
# \g | $wingp/gnuplot -p -e "set nokey; set size square; p '-'"

↓ クエリ結果のうち第
# \g | $wingp/gnuplot -p -e "set nokey; p '-' u 3:4 w lines"

psql から gnuplot の対話型シェルにデータを渡す
これは前回の対話モードと同じ構文。対話型シェルを起動する際には標準入力でデータを渡せないため、一時ファイルを作ってそのパスを渡します。gnuplot# \t on \\\pset format unaligned \\\f ' ' # \g tmp.dat \\\! $wingp/gnuplot -e "d='tmp.dat'; p d" -

gnuplot
gnuplot> p d u 3:4 w lines gnuplot> ...

gnuplot
psql から GUI 版 gnuplot を開いてデータを渡し、psql と並行作業
前項は# \g tmp.dat \\\! cygstart $wingp/wgnuplot -e "d='tmp.dat'" - # # (returned to psql) -- on gnuplot > print(d) tmp.dat > p d w filledcu > ...

四葉線の塗りがうまくいってませんが、データかプロットオプションの問題。wgnuplot
wgnuplot
-- no reaction # \g | $wingp/wgnuplot_pipes -p -e "p '-'" (input Ctrl-C and return to psql) #
(ConEmu なら)psql から別タブに gnuplot を開き、psql と並行作業
前項の# \g tmp.dat \\\! cygstart $wingp/gnuplot -e "d='tmp.dat'" - # # (returned to psql) -- on gnuplot > print(d) > set term dumb > p d > ...



前項と同様、psql
使いそうな場面別まとめ(前回を含む)
(A)クエリ結果をとにかく簡単に確認(データの値範囲、外れ値の有無など)…
(B)クエリを変えながら、1
…
(C)1
…
(D)グラフ用データを
…
(A)だけ