You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Treat stroke-symbols as other symbols unless -W is set #7788
It has annoyed me for some time that using symbols like cross, dash, etc., i.e., just line features, requires -W to set the pen thickness, making it very complicated to have variable pen widths. Also, color is not set by -G as for other symbols but taken from the pen. That color could come from a z/cpt lookup if -W+c is given. Etc. So while they are symbols they re second-class citizens in many ways.
Because of history an upgrade needs to be backwards compatible. I think this is:
If -W is used to set pen with constant color or variable via -W+c we honour that as the current solution as backwards compatibility.
If no-W then stroke symbol pen width is f * symbol_size, and if -G is set we set the pen to that color (same if z/cpt lookup)
This would allow -Sx14p -Gred to draw a red cross with pen width f *size and -Sx14p -Ct.cpt will do the same f * size but with pen color set via z/cpt.
So what is a reasonable f? Here are three candidates (ignore the other but reported in #7787) - I think going beyond this range gets odd: Please give your votes:
Note: As they say, different strokes for different blokes, one could also entertain a new GMT defaults MAP_STROKE_WIDTH that could default to our preferred choice but the users could override it for some project.
Maybe @GenericMappingTools/core and @GenericMappingTools/gmt-contributors can opine on the size to pen thickness issue? FYI, I think 15% is pretty good, but others may not, hence the MAP_STROKE_WIDTH (or a better word) is proposed.
There is no way to let Sx14p either be a cross with pen = default or pen = 15% of size. I know it has been like you state for 20 years but that was because we did not want users to plot nothing (no pen no fill) and be confused. I think we will have to let that go.
-Sx14p -Gred -W1p would be a red, 1p cross. Basically, we are treating all symbols the same way
To specifically answer @seisman questions and cases:
#!/bin/bash
gmt begin cases png
gmt basemap -R0/6/0/2 -JX15c/5c -B
echo 1 1 | gmt plot -Sx32p # black cross with the default pen
echo 2 1 | gmt plot -Sx32p -W1p,blue # 1p-thick blue cross (for backward compatibility)
echo 3 1 | gmt plot -Sx32p -Gred # 32*0.15-thick red cross (treat cross as a symbol)
echo 4 1 | gmt plot -Sx32p -Gred -W1p,black # 1p-thick black cross (for backward compatibility)
echo 5 1 | gmt plot -Sx32p -Gred -W1p # what will happen? 1p black cross or 1p red cross?
gmt end show
As for the two cases that fails to meet @seismanʻs expectation above:
Since Bush 1 administration we have decided that if a user is plotting a cross and do not set a pen (and setting -Gcolor has no affect since no filling), then we defaulted to the default pen to avoid user surprise at no plotting. Since not giving -W now scales the pen width I think the users will be happier with a size-appropriate pen than a skinny default pen. Those who have a script that never set -W can easily add one.
Stroke symbols always ignored -G, but the only reason anyone would use -G with a stroke symbol is of course they assume that will work. It never did, but does now.
So my proposal will
Case 1. Break an ancient and in retrospect bad default handling for no -W
Case 2. Retain backwards compatibility of -W is set (use 2)
Case 3. Get stroke color from -G if it is set
Case 4. No longer ignore -G for any symbol which always sets symbol color now
Case 5. Basically same as use 4
This PR will let all symbols assign color the same way (-G or CPT(z)). Note: I wish I had implemented this at the start bu such is life.
This scheme also fixes the problem of trying to place symbol codes in the data file. There were no way to use cross there and magically get variable pens or colors.
Finally, assigning colors and width to line segments is completely separate and will stay as before.
Sorry, I am very late coming into this discussion.
While I agree on the resulting agreement on how to handle -G and -W now, I have a reservation about MAP_STROKE_WIDTH for a couple reasons:
WIDTH to me should be something described in points (or whatever your favourite unit of length). This being a factor instead does not appear from the name.
MAP suggests that this has something to do with map frame or map annotations or other mapping issues. The settings starting with MAP_ are almost exclusively about that with just one or two exceptions.
The name MAP_STROKE_WIDTH does not at all point to symbols. The name suggests some overlap with MAP_DEFAULT_PEN.
I would therefore like to suggest two things:
Introduce a section to to settings called PLOT_ and rename MAP_STROKE_WIDTH to PLOT_SYMBOL_STROKE_FACTOR.
Also rename MAP_DEFAULT_PEN to PLOT_DEFAULT_PEN and rename MAP_VECTOR_SHAPE to PLOT_VECTOR_SHAPE.
Of course, very willing to discuss this particular issue further.
I'm OK with changing the new names, but as for the existing MAP_ settings I'm less sure. We say MAP and I agree that an x/y plot is not a map. However, there are lots of MAP_ ones that apply to plots and I see no real need to rename 15 defaults and deal with backwards compatibility checking. That was why i selected MAP_STROKE_WIDTH. I would be fine with MAP_SYMBOL_STROKE_FACTOR to avoid chasing so much all around GMT. Thoughts?
Activity
WIP Treat stroke symbols like other symbols
PaulWessel commentedon Sep 5, 2023
Maybe @GenericMappingTools/core and @GenericMappingTools/gmt-contributors can opine on the size to pen thickness issue? FYI, I think 15% is pretty good, but others may not, hence the MAP_STROKE_WIDTH (or a better word) is proposed.
seisman commentedon Sep 5, 2023
From what I understand:
-Sx14p: black cross with thedefaultpen-Sx14p -W1p,blue: 1p-thick blue cross (for backward compatibility)-Sx14p -Gred: 14*0.15-thick red cross (treat cross as a symbol)-Sx14p -Gred -W1p,black: 1p-thick black cross (for backward compatibility)-Sx14p -Gred -W1p: what will happen? 1p black cross or 1p red cross?PaulWessel commentedon Sep 5, 2023
There is no way to let Sx14p either be a cross with pen = default or pen = 15% of size. I know it has been like you state for 20 years but that was because we did not want users to plot nothing (no pen no fill) and be confused. I think we will have to let that go.
-Sx14p -Gred -W1p would be a red, 1p cross. Basically, we are treating all symbols the same way
PaulWessel commentedon Sep 6, 2023
Hei, @joa-quim @anbj @Esteban82 @maxrjones @seisman @remkos : Any opinion on this - otherwise I will
Implement at 15% size and no MAP_STROKE_WIDTH or similar.
anbj commentedon Sep 6, 2023
God morgen Pål,
20% is too much, 15% is good, 10% is good.
seisman commentedon Sep 6, 2023
Sounds good
PaulWessel commentedon Sep 6, 2023
To specifically answer @seisman questions and cases:
As for the two cases that fails to meet @seismanʻs expectation above:
So my proposal will
Case 1. Break an ancient and in retrospect bad default handling for no -W
Case 2. Retain backwards compatibility of -W is set (use 2)
Case 3. Get stroke color from -G if it is set
Case 4. No longer ignore -G for any symbol which always sets symbol color now
Case 5. Basically same as use 4
This PR will let all symbols assign color the same way (-G or CPT(z)). Note: I wish I had implemented this at the start bu such is life.
PaulWessel commentedon Sep 6, 2023
Final notes:
Esteban82 commentedon Sep 6, 2023
Fine by me.
Treat stroke symbols like other symbols (#7789)
remkos commentedon Sep 20, 2023
Sorry, I am very late coming into this discussion.
While I agree on the resulting agreement on how to handle -G and -W now, I have a reservation about
MAP_STROKE_WIDTHfor a couple reasons:MAP_are almost exclusively about that with just one or two exceptions.MAP_STROKE_WIDTHdoes not at all point to symbols. The name suggests some overlap withMAP_DEFAULT_PEN.I would therefore like to suggest two things:
PLOT_and renameMAP_STROKE_WIDTHtoPLOT_SYMBOL_STROKE_FACTOR.MAP_DEFAULT_PENtoPLOT_DEFAULT_PENand renameMAP_VECTOR_SHAPEtoPLOT_VECTOR_SHAPE.Of course, very willing to discuss this particular issue further.
PaulWessel commentedon Sep 20, 2023
I'm OK with changing the new names, but as for the existing MAP_ settings I'm less sure. We say MAP and I agree that an x/y plot is not a map. However, there are lots of MAP_ ones that apply to plots and I see no real need to rename 15 defaults and deal with backwards compatibility checking. That was why i selected MAP_STROKE_WIDTH. I would be fine with MAP_SYMBOL_STROKE_FACTOR to avoid chasing so much all around GMT. Thoughts?
remkos commentedon Sep 20, 2023
Fine by me, until someone complains about not understanding the scope of
MAP_:)PaulWessel commentedon Sep 20, 2023
We can certainly add some verbiage in the gmt.conf section about what we mean by MAP_ there so there is no confusion.
PaulWessel commentedon Sep 20, 2023
I will make a PR with the name change shortly.
Use MAP_SYMBOL_STROKE_FACTOR instead of MAP_STROKE_WIDTH
Use MAP_SYMBOL_PEN_SCALE instead of MAP_STROKE_WIDTH (#7822)