I want create a matplotlib figure with two subplots of which one is a map. To add a basemap I use contextily. The axis ratio should be aspect="equal" and to ensure that both subplots nonetheless have the same height I set adjustable="datalim" for this axis. This works fine, but contextily does not seem to pick up this change of the axis limits and adds the basemap only to a part of the subplot.
I have prepared this minimal example:
import contextily as cx
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=1,ncols=2)
axes[0].plot([0,1],[0,1],marker="o")
axes[1].plot([7.60,11.13],[51.81,52.10])
axes[1].set(aspect="equal", adjustable="datalim")
cx.add_basemap(axes[1],crs="EPSG:4326")

This is not true... the aspect-ratio determines the scale between the x- and y- axis... not the relation between axes in a figure!
If you want the subplots to share the plot-extent, use
for further info, see
Update
OK, after your comment I think I get your problem... you want both axes to have the same height while the right axes has to maintain aspect-ratio to avoid image distortions, and in addition you want the right axes to have "tight" limits (e.g. showing only the image without margins)
Using
adjustable="datalim"causes the margin and there is no way to avoid this. What you actually want is to useadjustable="box"and then set the axes size to match the desired data limits.To do that you have to evaluate the desired aspect-ratio and set the axis-position accordingly. The following lines should do the job:
This will result in a figure looking somewhat like this since your map extent is extremely wide... (e.g. you'd need to make the first axes quite small to have them next to each other)
...since the constant re-shuffling of axes (especially together with geo-axes) can be quite tedious, I recommend that you also have a look at the package I'm developing :-D (EOmaps) which provides a basic LayoutEditor to ease the pain of re-arranging axes and maps in a figure... The corresponding code would then look somewhat like this: