2次元グラフ: psxy

#!/bin/sh
#
# GMTは関数プロットができないので 
# sin.dat を作成します.
#
echo | awk -f "-" <sin.dat
BEGIN{
  PI=4*atan2(1.0,1.0);
  for(i=0; i <100; i++) {
      x=-2*PI+4*PI/100*i; 
      print x,sin(x);
  }
}
EOF
#
# GMT コマンドの実行
#
gmtdefaults -D > ./.gmtdefaults
gmtset LABEL_FONT_SIZE 18p LABEL_FONT GothicBBB-Medium-EUC-H
#gmtset ANOT_FONT GothicBBB-Medium-EUC-H
psbasemap -JX10c/10c -R-6.28/6.28/-1/1 \
          -B1:"X軸":/0.2:"Y軸":WeSn -P -K > plot2d.eps
psxy sin.dat -JX -R -B -W1/255/0/0p  -P -O -K  >> plot2d.eps
psxy cos.dat -JX -R -B -W0.2/0/255/0p -Sc0.3c -P -O -K >> plot2d.eps
pstext -JX -R -B -P -O -G0/0/255<<EOF >> plot2d.eps
0 0 20 45 37 CM GMTは関数プロットができません.
EOF



3次元グラフ: grdview または psxyz

#!/bin/bash

gmtdefaults -D > ./.gmtdefaults
gmtset LABEL_FONT_SIZE 18p LABEL_FONT GothicBBB-Medium-EUC-H

grdmath -R-10/10/-10/10 -I0.5 X SIN Y SIN MUL X DIV Y DIV \
= plot3d.grd
grdview plot3d.grd -R-10/10/-10/10/-0.2/1 -JX10c/10c -JZ10c \
-Wm/255/0/0  -B2:"X軸":/2:"Y軸":/0.2:"Z軸":EwNsZ -E60/30 -P \
> plot3d.eps



等高線図: grdcontour

#!/bin/bash

gmtdefaults -D > ./.gmtdefaults
gmtset LABEL_FONT_SIZE 18p LABEL_FONT GothicBBB-Medium-EUC-H

grdmath -R-10/10/-10/10 -I0.2 X SIN Y SIN MUL X DIV Y DIV \
= contour.grd
grdcontour plot3d.grd -A0.2f6 -C0.1 -JX10c/10c -JZ10c \
-R-10/10/-10/10/-0.2/1 -Wa2/255/0/0 -Wc0.2/128/64/0 \
-B2:"X軸":/2:"Y軸":xWeSn -P > contour.eps



マルチプロット: -Xx-offset -Yy-offset

#!/bin/sh

gmtdefaults -D > ./.gmtdefaults
gmtset LABEL_FONT_SIZE 14p LABEL_FONT GothicBBB-Medium-EUC-H
gmtset ANOT_FONT_SIZE 8p

grdmath -R-10/10/-10/10 -I0.4 X SIN Y SIN MUL X DIV Y DIV \
= plot3d.grd

grdcontour plot3d.grd -A0.2f4 -C0.1 -JX4.5c/4.5c -JZ4.5c \
-R-10/10/-10/10/-0.2/1 -Wa2/255/0/0 -Wc0.2/128/64/0 \
-B2:"X軸":/2:"Y軸":xWeSn -P -K -X2c -Y2c> multi.eps

echo | awk -f "-" <<EOF >sin.dat
BEGIN{
  PI=4*atan2(1.0,1.0);
  for(i=0; i <100; i++) {
      x=-2*PI+4*PI/100*i; 
      print x,sin(x);
  }
}
EOF
psbasemap -JX4.5c/4.5c -R-6.28/6.28/-1/1 \
          -B1:"X軸":/0.2:"Y軸":WeSn -P -O -K -Y7c >> multi.eps
psxy sin.dat -JX -R -B -W1/255/0/0p  -P -O -K  >> multi.eps
psxy cos.dat -JX -R -B -W0.2/0/255/0p -Sc0.15c -P -O -K >> multi.eps
pstext -JX -R -B -P -O -K -G0/0/255<<EOF >> multi.eps
0 0 10 45 37 CM GMTは関数プロットができません.
EOF

grdview plot3d.grd -R-10/10/-10/10/-0.2/1 -JX4.5c/4.5c -JZ4.5c \
-Wm/255/0/0 -B2:"X軸":/2:"Y軸":/0.2:"Z軸":EwNsZ -E60/30 -P \
-X6.5c -Y-0.5c -O -K >> multi.eps

echo '-0.8  0 0 255  1  255 255 0' > b2y.cpt
grdgradient plot3d.grd -A45 -Gintensity.grd -Nt0.75 -V

grdview plot3d.grd -R-10/10/-10/10/-0.2/1 -JX4.5c/4.5c -JZ4.5c \
-Qs -Iintensity.grd -Cb2y.cpt \
-Wm/255/0/0 -B2:"X軸":/2:"Y軸":/0.2:"Z軸":EwNsZ -E60/45 -P \
-Y-7c -O  >> multi.eps

convert multi.eps multi.png
convert -geometry 100x100 multi.eps multi-s.png