Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
The problem comes from me drawwing a map via cartopy. I want to add a little sub_axes on the lower_right corner of the main axes. But it seems hard to set the location and size of the sub_axes.
The first thing I tried wasfig.add_axes()
. But it doesn't accepttransform
args, while thedocument says it should. Without thetransform
args, the location (left, bottom) and size (width, height) wasn't on the transform ofax
.
importmatplotlib.pyplotaspltfig,ax=plt.subplots(1,1)ax2=fig.add_axes([0.8,0,0.2,0.2],transform=ax.transAxes,projection='rectilinear')
The second I tried wasinset_axes
, which was very easy to use. But it doesn't acceptprojection
args.
frommpl_toolkits.axes_grid.inset_locatorimportinset_axesimportmatplotlib.pyplotaspltfig,ax=plt.subplots(1,1)# The following line doesn't workax2=inset_axes(ax,width='20%',height='20%',axes_kwargs={'projection':'rectilinear'})# Doesn't work neither:ax2=inset_axes(ax,width='20%',height='20%',projection='rectilinear')
I may get what I want byax.get_position()
, the set the position according it.
Metadata
Metadata
Assignees
Labels
No labels