Proper usage of -S~

I’m trying to get plot -S~ to work. I’m struggling on how to pass desired the symbol. According to the documentation for -S~

+s<symbol><size>

Specifies the code and size of the decorative symbol.

I was unable to find anything on what the +s option expects exactly. I assumed it to be similar to -Sk and tried

-S~d30p:+striangle10p

without luck:

plot [WARNING]: riangle10 not a valid number and may not be decoded properly.

That lead me to assume that only the first character after the +s is parsed as symbol. Trying

-S~d30p:+st10p

didn’t throw an error but plotted only the line. No symbols to be seen. Another try was the custom symbol syntax:

-S~d30p:+sktriangle/10p

which didn’t work as well and I get some warnings and a line:

plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [WARNING]: triangle/10 not a valid number and may not be decoded properly.
plot [ERROR]: Unrecognized symbol code (107 = 'k') passed to gmt_draw_custom_symbol

I get the feeling I’m missing something. Can somebody please nudge me in the right direction on the proper usage of -S~?

Here is the code I’m experimenting with:

cat > path1.txt << END
 1.5  0.9
 0.5  1.8
-0.5  1.6
-1.5  0.9
END

gmt begin symbol_line
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path1.txt -S~d30p:+sktriangle/10p -W1p,black
gmt end show

Thank you and all the best,
Kristof

See the test/psxy/decoratedlines.sh script for some examples.

Thank you @pwessel for the hint. I found my problem – by default no pen or fill is used on the symbol.

A pen and/or fill must be defined otherwise the symbol won’t be shown. I have expected that it is plotted with default values for pen and fill similar to -Sf and others.

-S~d30p:+st10p+gred
              ~~~~~

works. But I have two questions:

  • Why is the symbol angled? According to the docs default should be line parallel? The result doesn’t look line parallel to me. Maybe I’m not understanding it correctly.
  • Any way to use custom symbols? Unleash the power of custom symbols … on lines!

cat > path1.txt << END
-1.5 -1.5
 1.5  1.5
END

gmt begin symbol_line
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path1.txt -S~d50p:+st50p+gred -W1p,black
gmt end show

Not sure, will look as time allows.

Fixed in GitHub. Now with default pen if nothing specified. Not sure about custom symbols yet.

@pwessel that works like a charm – look what I can do now thanks to your efforts!

Thank you very much!

(Done with 6.1.0_58d597c_2020.04.02)

@pwessel if you are not sure why custom symbols would be beneficial have a look at nautical charts or NOAA Chart No 1 Part N. They have a great variety of different lines with symbols (anchors, ducks, divers, fishes, etc). I tried to build two easier ones with the given possibilities so you get an idea:

cat > path1.txt << END
-1.5 -0.5
-0.5  1.7
 1.5  1.5
END

cat > path2.txt << END
-1.5 -1
 0    1
 1.5  1.2
END

gmt begin symbol_line
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  # no entry
  gmt plot path1.txt -W0p,white+o158p/0 -Sf+192p/28p+c -Gred
  gmt plot path1.txt -W0p,white+o158p/0 -Sf+192p/6p+f+p17p,white
  gmt plot path1.txt -W4p,black,28_20_28_20_28_68
  # caution
  gmt plot path2.txt -W4p,black,8_4
  gmt plot path2.txt -W0p,white -S~d80p:+st50p+gblack+p3p,white -Gblack
  gmt plot path2.txt -W0p,white -S~d80p:+st28p+gyellow
  gmt plot path2.txt -W0p,white+o80p/0 -Sf+80p/10p+f+p3p,black
  gmt plot path2.txt -W0p,white+o80p/0 -Sf+80p/4p+f+p4p,yellow
  gmt plot path2.txt -W0p,white+o80p/0 -Sf+80p/1p+f+p3p,black
  gmt plot path2.txt -W0p,white+o80p/0 -Sf+80p/16p+f+p3p,black+l
gmt end show

Not a question if useful, just a question if possible. But I am past that now and am close to wrap up the implementation.

Hey @KristofKoch
Could you share the line you used to plot the arrow one ?
Thanks ! :slight_smile:

Sure, I’ll have to look for it in my “experiments” folder. I remember it being a finicky thing to get right. I’ll come back to you.

1 Like

Found it, @PlanetGus:

cat > path1.txt << END
-1.5 -1.5
-0.7 -1.25
-0.4 -1.1
-0.3 -1
-0.2 -0.8
-0.3 -0.6
-0.5 -0.5
-0.6 -0.2
-0.4  0
-0.1  0.3
 0.1  1
 1.5  1.5
END

gmt begin symbol_line
  gmt basemap -R-2/2/-2/2 -JM6i -Bafg1
  gmt plot path1.txt -S~d96p:+st12p+an+p1p,black+i -W0p,white+o32p/0
  gmt plot path1.txt -W5p,black,28_20+o2p --PS_LINE_CAP=square
  gmt plot path1.txt -W4p,white,28_20+o2p --PS_LINE_CAP=square
  gmt plot path1.txt -S~d96p:+st12p+an+gwhite+i -W0p,white+o32p/0
gmt end show 

Problems:

  • Your line can’t start outside the map frame or the illusion will fall apart.
  • Doesn’t work with -W+s. [Edited this post to remove it]

Have fun and kindly let me know when you improved it.

Am trying to find a more adaptative solution… and so far nothing worked.
I’m trying to find a way to generate vector parameters from the coordinates similar to

at p0 : lon0 lat0 az(p0:p1) dist(p0:p1)
at p1 : lon1 lat1 az(p1:p2) dist(p1:p2)
...

with eventually the possibility to have dist(pN:pN+1) being a fraction of the actual distance then interpolate extra points in-between.
But I couldn’t find a more elegant solution than doing it on Matlab.

@moderators, is there an option to plot vectors along a track knowing lon,lat only ?

The closest I found was project but it’s not quite right.

And plot -Sv requires lon,lat,length,azimut

?
Thanks

mapproject -Af will compute azimuths along track. You will have to get your length inserted though.

I did that, but -Sv wants angle (cartesian) no?

If Cartesian then you get Cartesian angle I think… Inot (you get Cartesian azimuth) then for -Sv you would need to use -i on that column to add 90 and scale by -1