You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support inset_axes zooms for all GeoAxes projections #133
Traceback (most recent call last):
File "test_del.py", line 16, in <module>
zoom_kw={'color': 'red3', 'lw': 2}
File "/yin_raid/xin/miniconda3/envs/python37/lib/python3.7/site-packages/proplot/subplots.py", line 217, in _iterator
ret.append(func(*args, **kwargs))
File "/yin_raid/xin/miniconda3/envs/python37/lib/python3.7/site-packages/proplot/axes.py", line 1334, in inset_axes
bb = locator(None, None)
File "/yin_raid/xin/miniconda3/envs/python37/lib/python3.7/site-packages/proplot/axes.py", line 348, in inset_locator
bb = mtransforms.TransformedBbox(bbox, trans)
File "/yin_raid/xin/miniconda3/envs/python37/lib/python3.7/site-packages/matplotlib/transforms.py", line 1005, in __init__
raise ValueError("'transform' must be an instance of "
ValueError: 'transform' must be an instance of 'matplotlib.transform.Transform'
This is actually not an advertised feature but it's on my to-do list under the category "make XYAxes features work with rectangular projections like Mercator and Plate Carrée". See #131 for details.
Will leave this issue open as a feature request for now. As a workaround you can probably make your own inset axes using the default cartopy API with e.g.
The bounds are relative to axis, is it possible to use lon and lat?
If I set transform='data', I got this error:
~/new/miniconda3/envs/pyresample_min/lib/python3.8/site-packages/matplotlib/cbook/__init__.py in _check_isinstance(_types, **kwargs)
2244 for k, v in kwargs.items():
2245 if not isinstance(v, types):
-> 2246 raise TypeError(
2247 "{!r} must be an instance of {}, not a {}".format(
2248 k,
TypeError: 'transform' must be an instance of matplotlib.transforms.Transform, not a cartopy.crs.PlateCarree
In v0.7 I try to translate transform='data' into transform=ccrs.PlateCarree() so that you can position with longitude-latitude bounds rather than map projection bounds... but I guess matplotlib's axes positioning system can't handle cartopy transforms like its plotting commands can.
You can use transform=ax.transData instead for now -- since you're using the Plate Carrée projection, "map projection coordinates" are equivalent to longitude-latitude coordinates
This seems to work pretty well for Plate Carree projections in the latest version. Have to set manually set the left/bottom spaces or else the result is wrong... but not too much effort.
Activity
lukelbd commentedon Apr 22, 2020
This is actually not an advertised feature but it's on my to-do list under the category "make
XYAxesfeatures work with rectangular projections like Mercator and Plate Carrée". See #131 for details.Will leave this issue open as a feature request for now. As a workaround you can probably make your own inset axes using the default cartopy API with e.g.
zxdawn commentedon Jul 30, 2021
@lukelbd
I tried this feature again:
The bounds are relative to axis, is it possible to use lon and lat?
If I set
transform='data', I got this error:lukelbd commentedon Jul 30, 2021
In v0.7 I try to translate
transform='data'intotransform=ccrs.PlateCarree()so that you can position with longitude-latitude bounds rather than map projection bounds... but I guess matplotlib's axes positioning system can't handle cartopy transforms like its plotting commands can.You can use
transform=ax.transDatainstead for now -- since you're using the Plate Carrée projection, "map projection coordinates" are equivalent to longitude-latitude coordinateszxdawn commentedon Jul 30, 2021
@lukelbd Thanks, here's the example:
However, grid labels are wrong and no "zoom in" lines are plotted:

lukelbd commentedon Jan 24, 2022
This seems to work pretty well for Plate Carree projections in the latest version. Have to set manually set the left/bottom spaces or else the result is wrong... but not too much effort.
Non-Plate Carree are a different story thought. Again matplotlib isn't supplying the correct bounds:
Since the issue with using the wrong "transform" is fixed I'll remove the "bug" tag.
[-]inset_axes for geographic plots[/-][+]Support inset_axes zooms for all GeoAxes projections[/+]