Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maxrjones opened this issue Mar 2, 2022 · 5 comments · Fixed by #6450
Closed

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

maxrjones opened this issue Mar 2, 2022 · 5 comments · Fixed by #6450
Assignees
Labels
feature request Request a new feature

Comments

@maxrjones
Copy link
Member

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.

@PaulWessel
Copy link
Member

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.

@maxrjones
Copy link
Member Author

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

@PaulWessel
Copy link
Member

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

@maxrjones
Copy link
Member Author

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

@PaulWessel
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Request a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants