Open
Description
Description of the problem
To get the region
of the a PyGMT Figure, fig.region
can be used. In case a figure contains different plots with different regions, fig.region
always provides the region
related to the first plot. This affects the hlines
and vlines
methods. By default, a line is plotted extending over the complete plotting region. This leads to unexpected / wrong lines for the second and following plots, as the region values related to the first plot are used. A workaround is to explicitly specify the limits.
Minimal Complete Verifiable Example
import pygmt
fig = pygmt.Figure()
fig.basemap(region=[-1, 1, -1, 1], projection="X4c", frame=1)
print(fig.region) # [-1. 1. -1. 1.]
fig.hlines(y=0)
fig.vlines(x=0)
fig.shift_origin(xshift="w+1c")
fig.basemap(region=[-2, 2, -2, 2], projection="X4c", frame=1)
print(fig.region) # still [-1. 1. -1. 1.]
fig.hlines(y=0)
fig.vlines(x=0)
fig.show()
Full error message
NaN.
System information
PyGMT information:
version: v0.14.1.dev10
System information:
python: 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:20:11) [MSC v.1938 64 bit (AMD64)]
executable: C:\ProgramData\Anaconda3\envs\pygmt_env_dev_650\python.exe
machine: Windows-10-10.0.19045-SP0
Dependency information:
numpy: 1.26.4
pandas: 2.2.0rc0
xarray: 2024.3.0
netCDF4: 1.6.5
packaging: 24.0
contextily: 1.6.0
geopandas: 0.14.3
IPython: 8.22.2
pyarrow: None
rioxarray: 0.15.4
gdal: 3.8.2
ghostscript: 10.03.0
GMT library information:
version: 6.5.0
padding: 2
share dir: C:/Program Files (x86)/gmt6/share
plugin dir: C:/ProgramData/Anaconda3/envs/pygmt_env_dev_650/Library/bin/gmt_plugins
library path: C:/ProgramData/Anaconda3/envs/pygmt_env_dev_650/Library/bin/gmt.dll
cores: 4
grid layout: rows
image layout:
binary version: 6.5.0