Skip to content

Latest commit

History

25 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Gnuplot notes and libraries

Initialization for PDF for papers/slides

setencoding utf8setminussignsetterminal pdfcairo size3.5,3.5/sqrt(2)setoutput'a.pdf'

Settings for error bands

ToDo

Dashtypes

ToDo

libstrmath.gp

Functions:

  • strtext(tex_source), strtex(tex_source)
  • strmath(tex_source)

Variables:

  • strmath_font_math{rm,it,bm} ... These variables can be set to font names to configure respective fonts in mathematical expressions.
  • strmath_font_setup_{times,sans,aghtex,cmu,cmu_sans} ... These variables can be evaluated to set up the font variables with a preset configuration.

Example:

load'libstrmath.gp'# font settingsstrmath_font_mathrm = 'Times'strmath_font_mathit = 'Times:Italic'strmath_font_mathbm = 'Times:Italic:Bold'# The above settings are equivalent to the following line:#eval strmath_font_setup_timessetxlabelstrtext('Transverse momentum $p_T$ GeV/$c$')setylabelstrtext('$v_2\{2\}$')

If your system does not have good fonts, the following list shows typical fonts.

Typical faces similar to "Helvetica, Times, Courier, etc."
$ sudo pacman -Sy gnu-free-fontsUnicode fonts for CJK
$ sudo pacman -Sy noto-fonts-cjkLatin Modern and CMU (Math fonts)
$ sudo pacman -Sy texlive-fonts{recommended,extra}
$ mkdir -p ~/.local/share/fonts
$ ln -s /usr/share/texmf-dist/fonts/opentype/public/{lm,cm-unicode} ~/.local/share/fonts/
$ fc-cache -fv

Tips

線の両端点が範囲外の時に線が描画されない問題は以下の設定で回避できる

setclip two

三次元プロットで set view 0,0 としていたが、set pm3d map でも同様にできる?

setpm3d map

ファイルなしで using の中を全部式で指定したい場合は '+' というファイル名を 使う。二次元グリッドを生成するには '++' を使えるらしい。

plot ..., [t=-3:25:1] '+'using (t):(f(t))

with yerrorlines を使う時は白い円盤が他のデータ点を隠してしまうので以下を設定する

setpointintervalbox 0

三次元プロット splot の x-y 平面が変な所に表示される問題。これは以下を設定する。

setticslevel0

gnuplot 6.0 には対数目盛にバグがある。目盛りが $10^{n}$ ($n\ge 2$) の時、変な場 所に目盛りが表示される。正しく表示する為には、目盛りの位置をすべて手動で指定す るしかない。例えば以下の様にする。3番目の数字 1 は短い目盛り (minor tics) で ある事を示す。

setytics ( \  |1e-10, 1e-8, 1e-6, 1e-4, 1e-2, 1.0, \  |
""1e-91, ""2e-91, ""3e-91, ""4e-91, ""5e-91, ""6e-91, ""7e-91, ""8e-91, ""9e-91, \
""1e-71, ""2e-71, ""3e-71, ""4e-71, ""5e-71, ""6e-71, ""7e-71, ""8e-71, ""9e-71, \
""1e-51, ""2e-51, ""3e-51, ""4e-51, ""5e-51, ""6e-51, ""7e-51, ""8e-51, ""9e-51, \
""1e-31, ""2e-31, ""3e-31, ""4e-31, ""5e-31, ""6e-31, ""7e-31, ""8e-31, ""9e-31, \
""1e-11, ""2e-11, ""3e-11, ""4e-11, ""5e-11, ""6e-11, ""7e-11, ""8e-11, ""9e-11 )

pm3d で部分的にラスターで出力

pm3d で表示する時、メッシュが細かいと生成される PDF が巨大になってしまう。PNG で出力すれば良いかもしれないがそうすると、論文で文字列もラスターになってしまう し選択できない。pm3d の部分だけ画像埋め込みにできれば良いがその様な機能は提供 されていない。代わりに .png で生成した画像を with rgbimage で PDF に埋め込 むことを考える (gnuplot 4.4 以降で可能)。

先ずは pm3d の画像部分だけを生成する。

# xrange, yrange, cbrange や set log などは目的のプロットと同じにする。自動調整# だと一致させられないので全部手動で指定する。setpm3d mapsetxrange [...]setyrange [...]setcbrange [...]setterminal pngcairo size IMAGE_WIDTH,IMAGE_HEIGHTsetoutput'tmp.png'# 余計な物は全部消すsetlmarginat screen 0.0setrmarginat screen 1.0setbmarginat screen 0.0settmarginat screen 1.0unsetkeyunsetxticsunsetyticsunsetzticsunsetborderplot ...

その後で multiplot で重ねてプロットする。

setpm3d mapsetmultiplot# [...配置コマンド]setxrange [0:IMAGE_WIDTH-1]setyrange [0:IMAGE_HEIGHT-1]unsetkeyunsetxticsunsetyticsunsetbordersplot'tmp.png'binaryfiletype=pngwith rgbimage
# [...配置コマンド]setborder ...setxtics ...setytics ...setkey ...setxrange [...]setyrange [...]setcbrange [...]setzrange [0:1.0]splot-1.0# 枠および他の物を表示する為にダミーでプロットunsetmultiplot

ファイルの存在判定

そういう関数は存在しない。なので system(...) でシェルを呼び出す。

file_exists(file) = system("[ -f '".file."' ] && echo '1' || echo '0'") + 0

既定の設定

setxtics autosetytics autosetkeydefault

set format に関しては既定に戻す設定はない。既定の設定と同じ設定を手で指定する 必要がある。古いマニュアルだと % g になっているが、新しいマニュアルだと % h または LaTeX 系の出力では $%h$ ということになっている。

setformat x '% h'setformat y '% h'

対数目盛りのラベルは例えば以下の様に設定する

# Note: 本当は "%t e%+T" だが、対数軸の時は基本的に %t = 1.0 で固定なのでsetformat y '10^{%T}'# Note: もしちゃんと小数部も表示したければ例えば以下の様にするsetformat y '%.1t×10^{%T}'

ラベルを表に

既定ではラベルはグラフのプロットよりも裏に表示されるので 3d plot などだと見えな くなってしまう。表に表示するには front を指定する。

setlabel1 ... front

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages