Closed
Description
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 |
---|---|
![]() |
![]() |
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
- Implement the permanent shift:
Figure.shift_origin()
Add a new method to shift plot origins #289 - Implement temporary shift (i.e., reverting to the old plotting origin after plotting):
with Figure.shift_origin(): ...
Figure.shift_origin: Support shifting origins temporarily when used as a context manager #2509 - Docstrings are complete and easy to read
- Add Add a good tutorial example
- Full type hints
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
5) Ongoing maintenance