How to rotate once defined custom symbol

Added by Dariusz 2 months ago

What to add to such a line:

gmt psxy -R -J symbol_name.d -Sksymbol_name -Wthinnest -O -K >> %ps%
to draw symbol rotated for example by 30 degrees. So far I have added
30    R
at the beginning of the symbol_name.def file. But this would be only definition for a single instance of that symbol on the map ... What if a symbol needs to be used many times rotated in many ways ?


Replies (6)

RE: How to rotate once defined custom symbol - Added by Paul 2 months ago

You let the angle be the second parameter to the symbol and now your data file needs x y angle. See the appendix on custom symbols with arguments.

RE: How to rotate once defined custom symbol - Added by Dariusz 2 months ago

Paul wrote:

You let the angle be the second parameter to the symbol

Thank you for your answer but I don't understand this at all. Could you write a code ? And can't find any chapter entitled "Appendix" in pdf files. Do you mean CHAPTER 28 "Custom Plot Symbols" in the GMT_Docs.pdf ?

RE: How to rotate once defined custom symbol - Added by Paul 2 months ago

I am looking at https://www.generic-mapping-tools.org/gmt/latest/GMT_Docs.html#app-custom-symbols
As an example of a symbol that expects a z-value which is an azimuth and then draws a line in that direction:

# Macro for drawing a line in azimuth taken from input file
N:      1       a
# First rotate vertical by azimuth
$1      R
# Draw the direction line straight up
0    0       M
0    0.5     D
S


echo 0 0 30 | gmt psxy -R-2/2/-2/2 -JX4i -Bafg1 -Skdir/1i -W1p > t.ps

RE: How to rotate once defined custom symbol - Added by Paul 2 months ago

The symbol I just called dir.def here.

RE: How to rotate once defined custom symbol - Added by Dariusz 2 months ago

It works. Thank you. I added these lines:

N:      1       a
$1      R
at the beginning of the .def file instead of
30    R
However the symbol seems to be rotated by about 60 degrees left. This:
N:      1       r
$1      R
works too, but the symbol looks like rotated 30 deg left.
The .d file contains this line:
19.25 54.20 10.0 30.0
Third column is the size, fourth column supposed to be the angle.
This is interesting, that $ symbol works, because Windows .bat files use % instead. For example
... >> %ps%
instead of
... >> $ps
But this is .def file, not .bat.

RE: How to rotate once defined custom symbol - Added by Paul 2 months ago

Documentation explains the difference between a and r, and you need to design what you want to draw knowing that and what the symbol does for 0 degrees. And of course $, % only have special meanings on a command line, not in a text file like here.

(1-6/6)