Skip to content

Treat stroke-symbols as other symbols unless -W is set #7788

Closed

Description

@PaulWessel

Description of the desired feature

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.

line_symbols_10

line_symbols_15

line_symbols_20

Activity

  1. added
    feature request
    on Sep 5, 2023
  2. self-assigned this
    on Sep 5, 2023
  3. PaulWessel commented on Sep 5, 2023

    @PaulWessel
    ContributorAuthor

    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.

  4. seisman commented on Sep 5, 2023

    @seisman
    Member

    From what I understand:

    • -Sx14p: black cross with the default pen
    • -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?
  5. PaulWessel commented on Sep 5, 2023

    @PaulWessel
    ContributorAuthor

    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

  6. PaulWessel commented on Sep 6, 2023

    @PaulWessel
    ContributorAuthor

    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.

  7. anbj commented on Sep 6, 2023

    @anbj
    Contributor

    God morgen Pål,

    20% is too much, 15% is good, 10% is good.

  8. seisman commented on Sep 6, 2023

    @seisman
    Member

    MAP_STROKE_WIDTH or similar.

    Sounds good

  9. PaulWessel commented on Sep 6, 2023

    @PaulWessel
    ContributorAuthor

    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
    

    cases

    As for the two cases that fails to meet @seismanʻs expectation above:

    1. 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.
    2. 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.

  10. PaulWessel commented on Sep 6, 2023

    @PaulWessel
    ContributorAuthor

    Final notes:

    • 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.
  11. Esteban82 commented on Sep 6, 2023

    @Esteban82
    Member

    Hei, @joa-quim @anbj @Esteban82 @maxrjones @seisman @remkos : Any opinion on this

    Fine by me.

  12. added
    add-changelog
    on Sep 6, 2023
  13. remkos commented on Sep 20, 2023

    @remkos
    Contributor

    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.

  14. reopened this on Sep 20, 2023
  15. PaulWessel commented on Sep 20, 2023

    @PaulWessel
    ContributorAuthor

    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?

  16. remkos commented on Sep 20, 2023

    @remkos
    Contributor

    Fine by me, until someone complains about not understanding the scope of MAP_ :)

  17. PaulWessel commented on Sep 20, 2023

    @PaulWessel
    ContributorAuthor

    We can certainly add some verbiage in the gmt.conf section about what we mean by MAP_ there so there is no confusion.

  18. PaulWessel commented on Sep 20, 2023

    @PaulWessel
    ContributorAuthor

    I will make a PR with the name change shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

add-changelogfeature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions