diff --git a/gmtxy-image.sh b/gmtxy-image.sh index 126ac43..9e80eac 100755 --- a/gmtxy-image.sh +++ b/gmtxy-image.sh @@ -12,8 +12,10 @@ overwriteRange='null' overwrite=0 labels=("x (m)" "y (m)") plotgrad=0 +axistick=("a" "a") #横纵坐标轴间隔 a表示自动 +bartick="a" #色标轴标轴间隔 a表示自动 # 从命令行获取参数 -while getopts "hi:r:u:c:a:G:g" arg +while getopts "hi:r:u:c:a:G:t:v:g" arg do case $arg in h) @@ -24,6 +26,8 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z printf "%s\t%s\n" "-r" "data range. The template will ditect the input data range automaticly, the use of this option will overwrite the range." printf "%s\t%s\n" "-u" "data unit. The default is meter." printf "%s\t%s\n" "-c" "color cpt. The default is rainbow." + printf "%s\t%s\n" "-t" "intervals of axis's labels. the script will set the intervals automatically if -t option is not set." + printf "%s\t%s\n" "-v" "intervals of color bar's labels. the script will set the intervals automatically if -v option is not set." printf "%s\t%s\n" "-a" "axis labels. The deafults are x (m) and y (m)." printf "%s\t%s\n" "-g" "use grdgradient. The default is false." printf "%s\t%s\n" "-G" "provide a different input grid data for the use of grdgradient. This should be used with the '-g' option at the same time" @@ -34,6 +38,10 @@ For futher explanations, please look for GMT's manuscripts.\nAuthor: Yi Zhang (z unit=$OPTARG;; c) color=$OPTARG;; + t) + axistick=(${OPTARG//,/ });; + v) + bartick=$OPTARG;; r) overwrite=1 overwriteRange=$OPTARG;; @@ -67,12 +75,13 @@ else gmt gmtset \ FONT_ANNOT_PRIMARY=7p,Times-Roman,black \ MAP_FRAME_PEN=thin,black \ - MAP_TICK_LENGTH_PRIMARY=2p/1p \ + MAP_TICK_LENGTH_PRIMARY=1p/0.5p \ MAP_TITLE_OFFSET=7p \ - MAP_GRID_CROSS_SIZE_PRIMARY=4p \ + MAP_GRID_CROSS_SIZE_PRIMARY=2p \ FONT_LABEL=7p,Times-Roman,black \ MAP_FRAME_AXES=WeSnZ \ - MAP_LABEL_OFFSET=4p + MAP_LABEL_OFFSET=2p \ + MAP_ANNOT_OFFSET_PRIMARY=2.5p gmt grd2cpt ${data} -C${color} -R${range} -Z -D > $cptfile if [[ $plotgrad == 1 ]]; then @@ -82,11 +91,18 @@ else else gmt grdgradient ${gridData} -G${gradfile} -Nt -A0/45 fi - gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JX3i -K -P > $psfile + gmt grdimage ${data} -R${range} -C${cptfile} -I${gradfile} -Bx${axistick[0]}g+l"${labels[0]}" -By${axistick[1]}g+l"${labels[1]}" -JX1.5i -K -P > $psfile else - gmt grdimage ${data} -R${range} -C${cptfile} -Bxag+l"${labels[0]}" -Byag+l"${labels[1]}" -JX3i -K -P > $psfile + gmt grdimage ${data} -R${range} -C${cptfile} -Bx${axistick[0]}g+l"${labels[0]}" -By${axistick[1]}g+l"${labels[1]}" -JX1.5i -K -P > $psfile + fi + + #-C${cptfile}+Uk 使用km(色标单位除1000 + #如果unit等于km则在cptfile后面添加+Uk + if [[ ${unit} == 'km+Uk' ]]; then + gmt psscale -Dx1.6i/0.1i+w1.2i/0.07i -C${cptfile}+Uk -Bx${bartick} -By+l${unit} -O >> $psfile + else + gmt psscale -Dx1.6i/0.1i+w1.2i/0.07i -C${cptfile} -Bx${bartick} -By+l${unit} -O >> $psfile fi - gmt psscale -Dx3.2i/0.3i+w2.2i/0.1i -C${cptfile} -Bxa -By+l${unit} -O >> $psfile gmt psconvert $psfile -A -TEG -E300 # 删除临时文件 使用linux终端rm命令 rm $cptfile $psfile gmt.history gmt.conf