Legend

Hello forum,
how can i get a legend in an automatic way. this is my code:
gmt begin italy png,pdf

gmt set IO_COL_SEPARATOR=tab

gmt set GMT_THEME cookbook

gmt info C:\programs\radon_sicilia.txt

gmt coast -R11.72763/13.73163/37.35795/38.25725 -Wthin -B -JM5i -I1

gmt grdimage @earth_relief_01s -R11.72763/13.73163/37.35795/38.25725 -I+d

gmt makecpt -Cred,yellow,blue -T0,30,60,90 -N

gmt plot C:\programs\seismicity_radon.txt -C -Sci -Wfaint -i0,1,3,2+s0.015

gmt plot C:\programs\SHP\ISS330.shp -Wthin,black

gmt plot C:\programs\SHP\DSS330.shp -Wthin,yellow

gmt plot C:\programs\SHP\CSSTOP330.shp -Wthin,green

gmt plot C:\programs\SHP\CSSPLN330.shp -Wthin,coral

gmt plot C:\programs\SHP\SUBDCNT330.shp -Wthin,purple

gmt plot C:\programs\SHP\SUBDZON330.shp -Wthin,gray

gmt plot C:\programs\radon_sicilia.txt -St0.10i -Gyellow

gmt text C:\programs\radon_sicilia_1.txt -F+f5p,Times-Bold,white

gmt image c:\programs\north.jpg -Dg11.50000/38.70000+w0.50 -R11.50000/12.00000/38.70000/39.00000

gmt end show

Thanks you !

Have a look at -l in the doc
plot [...] -l"my legend"

1 Like

Thanks. I automatically understood how to do it.
Very useful.
If I had to do it manually, the synthesis I did not understand what it is.
Do you see this EOF being used? Where should I place it?

EOF stands for “End Of File” (note that the keyword END, (?or pretty much anything?) works too). It tells the function you’re calling to wait the next keyword (here EOF) to run and that you’re feeding its content on the go.

ie :

cat > file.txt <<-EOF
a string
EOF

It says cat: display the content of this unspecified file and write it in file.txt. Oh ! Wait, this unspecified file actually is given between "EOF"s

So if you want to use gmt legend file.txt … that’s how you create the file.txt.

Does it help?

I do this but i have this mestake.

C:\Users\Anna>gmt legend -Dg9.00000/36.00000+w3c+o0.25c -F+p1p+ggray95+s file.txt
legend [ERROR]: Cannot find file file.txt
<< non atteso.
C:\Users\Anna>cat > file.txt <<-EOF
(base) PS C:\Users\Anna>

Could you share your full script?

This doesn’t work in plain Windows batch language.

gmt begin italy png,pdf

gmt set IO_COL_SEPARATOR=tab

gmt set GMT_THEME cookbook

gmt info C:\programs\radon_sicilia.txt

gmt coast -R11.72763/13.73163/37.35795/38.25725 -Wthin -B -JM5i -I1

gmt grdimage @earth_relief_01s -R11.72763/13.73163/37.35795/38.25725 -I+d

gmt makecpt -Cred,yellow,blue -T0,30,60,90 -N

gmt plot C:\programs\seismicity_radon.txt -C -Sci -Wfaint -i0,1,3,2+s0.015

gmt plot C:\programs\SHP\ISS330.shp -Wthin,black -lFault1+H"LEGEND"+f16p+D

gmt plot C:\programs\SHP\DSS330.shp -Wthin,yellow -lFault2+H"LEGEND"+f16p+D

gmt plot C:\programs\SHP\CSSTOP330.shp -Wthin,green -lFault3+H"LEGEND"+f16p+D

gmt plot C:\programs\SHP\CSSPLN330.shp -Wthin,coral -lFault4+H"LEGEND"+f16p+D

gmt plot C:\programs\SHP\SUBDCNT330.shp -Wthin,purple -lFault5+H"LEGEND"+f16p+D

gmt plot C:\programs\SHP\SUBDZON330.shp -Wthin,gray -lFault6+H"LEGEND"+f16p+D

gmt plot C:\programs\radon_sicilia.txt -St0.10i -Gyellow -lRadonStation+H"LEGEND"+f16p+D

gmt text C:\programs\radon_sicilia_1.txt -F+f5p,Times-Bold,white

gmt image c:\programs\north.jpg -Dg11.50000/38.70000+w0.50 -R11.50000/12.00000/38.70000/39.00000

gmt legend -Dg9.00000/36.00000+w3c+o0.25c -F+p1p+ggray95+s <<-EOF

L 10 C Legeng

EOF

gmt end show

This is the error, no my code.
i don’t know the correct syntax of windows batch file.

When in doubt, just abandon Windows batch since there are some many limitations and use bash scripting instead.

Uploading: gmt.JPG…

Paul if i use this extention i don’t see the output. Why? where is?

I have no idea what Windows Powershell might do. I dont think it is bash compatible. I suggest you install Git for windows which comes with bash.

1 Like

Do not use powershell. It screws in mysterious ways.

The above, other than not working in batch, has an error too. No leading minus before EOF.
In this case because it’s a single line you can replace it with

echo L 10 C Legeng | gmt legend -Dg9.00000/36.00000+w3c+o0.25c -F+p1p+ggray95+s

but in more elaborated cases you better use a bash shell like Paul advised.

1 Like

I recommend you this video (on Spanish) which it shows how to install the softwares on windows. I think it could help you.

1 Like