Skip to content

Keep track of -X -Y for clip paths in modern mode #6406

Closed

Description

@maxrjones

Description of the desired feature

Currently, users must specify any x-shifts and y-shifts applied to their plots when ending clip paths using coast -Q, clip -C, or mask -C. I am wondering if it would be feasible to keep track of these settings automatically in modern mode in a similar manner to how the -R -J history is tracked in insets, subplots, figures, etc?

For background, one motivation for this question is to simplify the use of these features in the wrappers by controlling the closure of clip paths automatically (e.g., GenericMappingTools/pygmt#1779). In addition to helping PyGMT, this would also simplify usage through the CLI.

Activity

  1. added
    feature request
    on Mar 2, 2022
  2. PaulWessel commented on Mar 5, 2022

    @PaulWessel
    Contributor

    Hm, not sure I understand actually. Can you illustrate this with a modern mode CLI script that shows what the trouble is? I am sure we could do something under the hood in modern mode as long as it can be backwards compatible with not doing it.

  3. maxrjones commented on Mar 7, 2022

    @maxrjones
    MemberAuthor

    Perhaps I am not correctly interpreting this sentence from the clip -C docs: "Remember to supply -X and -Y settings if you have moved since the clip started.".

    Here is a CLI example with -X used while the clip path is set (I am not sure why the second plot command does not affect the figure):

    cat << EOF > path1.txt
    1 1
    1 2
    2 2
    2 1
    EOF
    
    gmt begin clip_example png
    gmt basemap -R0/6/0/6 -JX3c -B
    gmt clip path1.txt -N -W
    gmt plot @tut_data.txt -Gred -Sc0.2c
    gmt plot @tut_data.txt -Ggreen -Sc0.2c -X4c # Why is this not plotted?
    gmt clip -C
    gmt end
    

    clip_example

  4. PaulWessel commented on Mar 7, 2022

    @PaulWessel
    Contributor

    The map is 3c wide and you move 4c so all green are outside the map clip area. Try -X2c

  5. maxrjones commented on Mar 7, 2022

    @maxrjones
    MemberAuthor

    The map is 3c wide and you move 4c so all green are outside the map clip area. Try -X2c

    Thanks - I missed this important section in the overview describing -N ("by plotting a clipping path along the map boundary").

    Can you explain what the sentence "Remember to supply -X and -Y settings if you have moved since the clip started" is warning against? The example below seems to work fine without supplying -X settings despite having moved since the clip path started.

    cat << EOF > path1.txt
    1 1
    1 2
    2 2
    2 1
    EOF
    
    gmt begin clip_example png
    gmt basemap -R0/6/0/6 -Jx1c -B
    gmt clip path1.txt -N -W
    gmt plot @tut_data.txt -Gred -Sc0.2c
    gmt plot @tut_data.txt -Ggreen -Sc0.2c -X1c
    gmt clip -C
    gmt basemap -R0/6/0/6 -Jx1c -B
    gmt plot @tut_data.txt -Gpurple -Sc0.1c
    gmt end
    

    clip_example

  6. PaulWessel commented on Mar 7, 2022

    @PaulWessel
    Contributor

    No, I cannot make sense of it either. I am sure it made sense to me at the time...

  7. self-assigned this
    on Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions