WANtaroHP (GMT tips)

toJA

Outline of this page

Contents


Rules of superimposition: >, >>, -K, -O

Many of reasons which cannot create a eps file are your miswriting signs.

set fig=fig_out.eps
psbasemap ........ -K > %fig%
psxy ............. -K -O >> %fig%
psxy ............. -K -O >> %fig%
・・・・・
・・・・・
pstext ............. -K -O >> %fig%
pstext ............. -O >> %fig%

If you want to use '-K -O' for all command lines except first and final lines, following command is available.

echo 0 0 | psxy -R -J -Sp -O >> %fig%

Above command is to make one point on the origin. I think this doesn't prevent your work.



-P

This argument -P is used to change the style of paper from landscape to portrait. Default is landscape. If you don't use -P, you don't have problem using 'gsview.' However, in case of changing image format from eps to png, you have to rotate the image by 90 degree.



-N

-N is a argument which is able to draw the symbol or text at out of graph area. However, data existing out of graph area is drawn if -N is used.



-H

-H is a argument to specify the header record in the input file. If -H2 is used, first and second rows are considered as header line and GMT reads data from 3rd row of input data file. If -H is not used, GMT reads data from first row of input data file.



-:

-: is a argument to change the order of data input. In default state, GMT reads data with the order of x (horizontal) and y (vertical). If -: is used, GMT reads data with the order of y (vertical) and x (horizontal).

In the case of earth coordinates, default order is (longitude, latitude). When -: is used, GMT consideres the order of data is (latitude, longitude).



-X, -Y

-X and -Y are arguments to set the coordinates for plot origin on the paper. Default values are specified in 'gmtdefaults' as 'X_ORIGIN' and 'Y_ORIGIN.' Thier values are both 2.5cm. This is available in the case of making multiple graphs.



-U

-U is a argument to draw the time stamp of GMT at left bottom on the graph. If strings are specified after -U like -Utext, specified text is drawn after the time stamp of GMT.



Specifying pen attributes using -W (psxy)

Sample commands

gawk "BEGIN{FS=\",\"}{if(568<=NR&&NR<=610)print $2,$5*1000}" %inp_1% | psxy -R -J -B -W5t15_5_5_5:0 -P -O -K >> %fig_out%
gawk "BEGIN{FS=\",\"}{if(568<=NR&&NR<=610)print $2,$5*1000}" %inp_2% | psxy -R -J -B -W5t10_10:0 -P -O -K >> %fig_out%
gawk "BEGIN{FS=\",\"}{if(568<=NR&&NR<=610)print $2,$5*1000}" %inp_3% | psxy -R -J -B -W5t5_5:0 -P -O -K >> %fig_out%
gawk "BEGIN{FS=\",\"}{if(568<=NR&&NR<=610)print $2,$5*1000}" %inp_4% | psxy -R -J -B -W5 -P -O -K >> %fig_out%

-W can specify the line type.

In above case, gawk reads data from input data file 'inp_1' and pass data to GMT.

-W5 Solid line with the width of 5
-W5t10_10:0 Broken line with the width of 5
-W5t5_5:0 Dotted line with the width of 5
-W5t15_5_5_5:0Dashed line with the width of 5

Followings are sample of simple specifying.

-W5,- Broken line with the width of 5
-W5,. Dotted line with the width of 5
-W5,-.Dashed line with the width of 5


Drawing solid line and arrow using -SvS (psxy)

Explanation

Batch file for above drawings are shown below.

set fig=fig_arrow1.eps
echo 0 0 90 4 | psxy -JX4/6 -R-2/2/-1/5 -Svt1/2/1 -W3 -P -K > %fig%
echo 0.0 -0.3 0.5 | psxy -JX -R -Sp -Ex -W1 -P -K -O >> %fig%
echo 0.5  4.3 0.5 | psxy -JX -R -Sp -Ex -W1 -P -K -O >> %fig%
echo 1.3  3.0 1.0 | psxy -JX -R -Sp -Ey -W1 -P -K -O >> %fig%
echo 0.0 -0.6 12  0 0 CM arrowwidth | pstext -R -J -N -P -K -O >> %fig%
echo 1.6  3.0 12 90 0 CM headlength | pstext -R -J -N -P -K -O >> %fig%
echo 0.5  4.6 12  0 0 CM headwidth | pstext -R -J -N -P -O >> %fig%

set fig=fig_arrow2.eps
gmtset VECTOR_SHAPE=-3
echo -3 0 0 1 | psxy -JX8/3 -R-4/4/-2/1 -SVb -P -K > %fig%
echo -3 -1 10 0 0 MC -3 | pstext -R -J -N -K -O >> %fig%
gmtset VECTOR_SHAPE=-2
echo -2 0 0 1 | psxy -J -R -SVb -P -K -O >> %fig%
echo -2 -1 10 0 0 MC -2 | pstext -R -J -N -K -O >> %fig%
gmtset VECTOR_SHAPE=-1
echo -1 0 0 1 | psxy -J -R -SVb -P -K -O >> %fig%
echo -1 -1 10 0 0 MC -1 | pstext -R -J -N -K -O >> %fig%
gmtset VECTOR_SHAPE=0
echo 0 0 0 1 | psxy -J -R -SVb -P -K -O >> %fig%
echo 0 -1 10 0 0 MC 0 | pstext -R -J -N -K -O >> %fig%
gmtset VECTOR_SHAPE=1
echo 1 0 0 1 | psxy -J -R -SVb -P -K -O >> %fig%
echo 1 -1 10 0 0 MC 1 | pstext -R -J -N -K -O >> %fig%
gmtset VECTOR_SHAPE=2
echo 2 0 0 1 | psxy -J -R -SVb -P -K -O >> %fig%
echo 2 -1 10 0 0 MC 2 | pstext -R -J -N -K -O >> %fig%
gmtset VECTOR_SHAPE=3
echo 3 0 0 1 | psxy -JX -R-4/4/-2/1 -SVb -P -K -O >> %fig%
echo 3 -1 10 0 0 MC 3 | pstext -R -J -N -K -O >> %fig%
rem
echo 0 -1.5 10 0 0 MC VECTOR_SHAPE | pstext -R -J -N -O >> %fig%

Sample commands

gmtset VECTOR_SHAPE 1
echo  2.50  1.7  2.50 -0.6 | psxy -R -J -SvS0.005/0.0/0.0 -G0 -O -K >> %fig_out%
echo -2.50 -0.5  2.50 -0.5 | psxy -R -J -SvS0.005/0.2/0.1 -G0 -O -K >> %fig_out%

-SvS can specify the simple line without arrow head and arrow (with arrow head).

In above sample, input data is set using 'echo' and passed to 'psxy' using pipe function of command prompt.



Plot data format (psxy)

Sample commands

set inp_dat=inp_dat1.txt
set fig_out=fig_out1.eps
..........
psxy %inp_dat% -R -JX -SC0.2 -G0 -N -O >> %fig_out%

-SC0.2 draws a circle with the diameter of 0.2cm.

In above sample, input file name 'inp_dat1.txt' and output image filename 'fig_out1.eps' are set using 'set' before GMT commands.

Input data column format (2 columns)

x  y
x x-coordinate (longitude)
y y-coordinate (latitude)


Drawing error bar in y-direction (psxy)

sample commands

set inp_dat=inp_dat1.txt
set fig_out=fig_out1.eps
..........
psxy %inp_dat% -R -JX -SC0.2 -G0 -Ey -N -O >> %fig_out%

A circle with the diameter of 0.2cm is drawn by -SC0.2 and error bar is drawn by -Ey. The inputted length of error bar means only one-side.

Input data column format (3 columns)

x  y  ey
x x-coordinate (longitude)
y y-coordinate (latitude)
ey error bar length in y-direction


Drawing error bars in x and y-directions (psxy)

Sample commands

set inp_dat=inp_dat1.txt
set fig_out=fig_out1.eps
..........
psxy %inp_dat% -R -JX -SC0.2 -G0 -Ex -Ey -N -O >> %fig_out%

A circle with the diameter of 0.2cm is drawn by -SC0.2 and error bars in x-direction and y-direction are drawn by -Ex -Ey.

Input data column format (4 columns)

x  y  ex  ey
x x-coordinate (longitude)
y y-coordinate (latitude)
ex error bar length in x-direction
ey error bar length in y-direction


Changing plot size (psxy)

Sample commands

set inp_dat=inp_dat1.txt
set fig_out=fig_out1.eps
..........
psxy %inp_dat% -R -JX -SC -G255 -W3 -N -O >> %fig_out%

In -SC, plot size is not specified. Plot size is specified in input data file.

Input data column format (3 columns)

x  y  z
x x-coordinate (longitude)
y y-coordinate (latitude)
z plot size


Changing plot color (psxy)

Sample commands

set inp_dat=inp_dat1.txt
set fig_out=fig_out1.eps
..........
psxy %inp_dat% -R -JX -SC0.5 -Cinp_wg_34cpt.cpt -N -O >> %fig_out%

A circle with the diameter of 0.5cm by -SC0.5 and color pallet filename is specified by -C. Plot color is defined based on the inputted z-value. If inputted z-value is between z1 and z2 specified in color pallet file, plot color is defined as the related RGB value defined in color pallet file.

Input data column format (3 columns)

x  y  z
x x-coordinate (longitude)
y y-coordinate (latitude)
z z-value related to color

Basic format of color pallet file

z1    R1  G1  B1  z2  R2  G2  B2
 0     0   0   0  20   0   0   0
20   255   0   0  40 255   0   0
40     0 255   0  60   0 255   0
60     0   0 255  80   0   0 255
80   255   0 255 100 255   0 255

Expression of color by RGB

Color R G B
Black 0 0 0
Red 255 0 0
Lime 0 255 0
Blue 0 0 255
Yellow 255 255 0
Fuchsia 255 0 255
Aqua 0 255 255
White 255 255 255


Changing plot color and size (psxy)

Sample commands

set inp_dat=inp_dat1.txt
set fig_out=fig_out1.eps
..........
psxy %inp_dat% -R -JX -SC -Cinp_wg_34cpt.cpt -N -O >> %fig_out%

Plot size is not specified in -SC, and plot size and plot color are specified based on inputted data of za and zb. Color pallet file is required to specify the color and it is specified using -C.

Input data column format (4 columns)

x  y  za  zb
x x-coordinate (longitude)
y y-coordinate (latitude)
za z-value related to color
zb plot size


-m (psxy)

It becomes possible to input multi data which is drawn using same linetype by '-m' option in the command of 'psxy.' The first row of data file shall be '>' and separator of data set shall be '>'

Sample data

sample data is shown in below. This data indicates 2 lines and they are drawn with same line type.

>
0.000 -2600.000
0.000  2500.000
>
-2600.000  0.000
 3300.000  0.000


Drawing text (pstext)

Sample commands

echo 0.02 0.85  8 0 0 TL text | pstext -R0/1/0/1 -JX8/4 -N -K -O >> %fig_out%

Text (string) is draw by 'pstext' command. Font No.0 means 'Helvetica.'

Input data column format (7 columns)

x  y  size  angle  fontno  justify  text
x x-coordinate (longitude)
y y-coordinate (latitude)
size font size in points
angle angle measured counterclockwise (rotation angle of string)
fontno font number
justifythe point on the text-string that should correspond to the given x, y location
text text string or sentence

Strings for justify are shown below.

TL(top-left) TC(top-center) TR(top-right)
ML(middle-left)MC(middle-center)MR(middle-right)
BL(bottom-left)BC(bottom-center)BR(bottom-right)

Mark up characters for symbol, superscript, subscript etc. are shown below.

CodeEffect
@~ Turns symbol font (Greek character) on or off
@+ Turns superscript on or off
@- Turns subscript on or off
@# Turns small caps on or off
@_ Turns underline on or off
@%fontno%Switches to another font; @%% resets to previous font
@:size: Switches to another font size; @:: resets to previous size
@;color; Switches to another font color; @;; resets to previous color
@! Creates one composite character of the next two characters
@@ Prints the @ sign itself

Relationship between Alphabet and Greek characters is shown below.



Use of minmax

Sample input data

test1.txt
(1 column data)
0.1
0.2
0.3
0.4
0.5
test2.txt
(2 columns data)
1 10
2 20
3 30
4 40
5 50
test5.txt
(5 columns data)
1 10 100 1000 10000
2 20 200 2000 20000
3 30 300 3000 30000
4 40 400 4000 40000
5 50 500 5000 50000

Usage

minmax test1.txt > out.txt
minmax test2.txt >> out.txt
minmax test5.txt >> out.txt

'test1.txt', 'test2.txt' and 'test5.txt' are input data file, and 'out.txt' is output file.

Output sample

test1.txt: N = 5	<0.1/0.5>
test2.txt: N = 5	<1/5>	<10/50>
test5.txt: N = 5	<1/5>	<10/50>	<100/500>	<1000/5000>	<10000/50000>

Format of result is shown below.

filename: N = nd  <min/max> ...  <min/max>
filename input filename
nd number of data row
min minimum value od the column
max maximum value of the column

toJA
inserted by FC2 system