Here's an image of US counties, created on top of
ax = plt.axes(projection=ccrs.LambertConformal())
ax.set_extent([-120, -70, 20, 50], ccrs.Geodetic())
In the "live" figure one can see with plt.show()
, there's a large gray area around the figure. Here you can (not) see it via the white padding.
So I thought I could zoom in a bit more:
ax.set_extent([-120, -70, 20, 40], ccrs.Geodetic())
And then this happened:
While there is still white margin/padding around the figure, it's suddenly cropped. The "live image" also is showing me some white margin that is apparently placed around the projection.
I tried plt.tight_layout()
, which indeed removed much of the margins, but left some (the second picture is taken after tightening the layout). This invisible margin makes it especially difficult to ax.set_extent()
, as I can't see until where I can extend the map.
Is there some way to remove all the hidden padding/margin around the projection?
You can use subplots_adjust
:
To remove all the whitespace from around the Axes
object, use:
fig.subplots_adjust(left=0, right=1, bottom=0, top=1)
Setting the extent
is changing the data limits, not the position/size of the Axes
.
来源:https://stackoverflow.com/questions/39410665/matplotlib-projection-remove-margin