Skip to content

Figure.shift_origin: Shifting plotting origins #2401

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
4 of 5 tasks
seisman opened this issue Mar 7, 2023 · 1 comment
Closed
4 of 5 tasks

Figure.shift_origin: Shifting plotting origins #2401

seisman opened this issue Mar 7, 2023 · 1 comment
Labels
feature request New feature wanted
Milestone

Comments

@seisman
Copy link
Member

seisman commented Mar 7, 2023

The Figure.shift_origin method is a high-level wrapper for GMT's common option -X/-Y. With this method, we should disallow -X/-Y option in all plotting methods.

The syntax of -X/-Y

The full syntax of GMT's -X and -Y options is (https://docs.generic-mapping-tools.org/dev/gmt.html#xy-full):

-X[a|c|f|r][xshift]

As mentioned in the upstream issue GenericMappingTools/gmt#7296, -Xc and -Xf make no sense in modern mode. So, we only focus on -Xr (the same as -X) and -Xa in PyGMT.

  • -Xr: move the origin relative to its current location.
  • -Xa: move the origin relative to its current location, and move the origin back to the original position after plotting

The following GMT bash script shows the behavior of -Xr and -Xa:

gmt begin                                                                       
for mode in "r" "a"; do                                                         
    echo "Shift plotting origin with -X${mode}10c"                              
    gmt figure shift-X${mode}10c png                                            
    gmt basemap -R0/10/0/10 -JX10c -Baf -B+tFrame1                              
    gmt basemap -R0/10/0/10 -JX10c -Baf -B+tFrame2 -X${mode}10c                 
    gmt basemap -R0/5/0/5 -JX5c -Baf -B+tFrame3                                 
done                                                                            
gmt end show 
-Xr -Xa
image image

Implementation of Figure.shift_origin

The Figure.shift_origin method should support both -Xr (shifting origins permanently) and -Xa (shiftiing origins temporarily). So, the most intuitive syntax is:

# Permanently shift the plotting origin
Figure.shift_origin(xshift="1c")  

# Temporarily shift the plotting origin
with Figure.shift_origin(xshift="1c"):
    ...
    ...

Issues to track

@seisman seisman added the feature request New feature wanted label Mar 7, 2023
@seisman seisman added this to the 0.10.0 milestone Apr 9, 2023
@weiji14 weiji14 removed this from the 0.10.0 milestone Aug 25, 2023
@seisman seisman changed the title Figure.shift_origin: Allow shifting the origin back to the original position after plotting Figure.shift_origin: Shifting plotting origins Feb 19, 2025
@seisman seisman moved this from 0) Wishlist to 1) Feature request issue in PyGMT: Wrapping GMT modules Feb 19, 2025
@seisman seisman moved this from 1) Feature request issue to 2) Initial implementation in PyGMT: Wrapping GMT modules Feb 19, 2025
@seisman seisman added this to the 0.15.0 milestone Feb 20, 2025
@seisman
Copy link
Member Author

seisman commented Feb 24, 2025

I feel the Figure.shift_origin documentation https://www.pygmt.org/dev/api/generated/pygmt.Figure.shift_origin.html is good enough and we also have many gallery examples that calls Figure.shift_origin, so a separate tutorial or gallery example is not necessary. So I'm closing this issue, and move Figure.shift_origin to "ongoing maintainence" category in the project board (PyGMT: Wrapping GMT modules).

@seisman seisman closed this as completed Feb 24, 2025
@github-project-automation github-project-automation bot moved this from 2) Initial implementation to 4) Gallery|tutorial example in PyGMT: Wrapping GMT modules Feb 24, 2025
@seisman seisman moved this from 4) Gallery|tutorial example to 5) Ongoing maintenance in PyGMT: Wrapping GMT modules Feb 24, 2025
@seisman seisman modified the milestones: 0.15.0, 0.1.x Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted
Projects
Status: 5) Ongoing maintenance
Development

No branches or pull requests

2 participants