-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
The first subplot is missized after savefig
to a png file.
#6457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you reproduce this without cartopy or pandas? |
I can give it a try later (someone is waiting for me, and getting angry). I'll try after I'm back. Thank you. |
On 2016/05/21 3:42 PM, WANG Aiyong wrote:
Like this? In [1]: fig, axs = plt.subplots(2, 3) In [2]: axs[-1][-1].set_visible(False) Eric |
@tacaswell |
@efiring ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-23-c8395ff141e8> in <module>()
51
52 axs[-1][-1].set_visible(False)
---> 53 fig.tight_layout()
54 #fig.savefig('a.png', dpi=300)
C:\anaconda\lib\site-packages\matplotlib\figure.py in tight_layout(self, renderer, pad, h_pad, w_pad, rect)
1752 renderer,
1753 pad=pad, h_pad=h_pad, w_pad=w_pad,
-> 1754 rect=rect)
1755
1756 self.subplots_adjust(**kwargs)
C:\anaconda\lib\site-packages\matplotlib\tight_layout.py in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
347 subplot_list=subplot_list,
348 ax_bbox_list=ax_bbox_list,
--> 349 pad=pad, h_pad=h_pad, w_pad=w_pad)
350
351 if rect is not None:
C:\anaconda\lib\site-packages\matplotlib\tight_layout.py in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
126 tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
127 tight_bbox = TransformedBbox(tight_bbox_raw,
--> 128 fig.transFigure.inverted())
129
130 row1, col1 = divmod(num1, cols)
C:\anaconda\lib\site-packages\matplotlib\transforms.py in __init__(self, bbox, transform, **kwargs)
1069 *transform*: a 2D :class:`Transform`
1070 """
-> 1071 if not bbox.is_bbox:
1072 raise ValueError("'bbox' is not a bbox")
1073 if not isinstance(transform, Transform):
AttributeError: 'NoneType' object has no attribute 'is_bbox'
|
Do you get the same result if you pass |
@fariza fig, axs = plt.subplots(3, 2, sharex=True, sharey=True,
figsize=(width*2, height*3),
dpi=300, subplot_kw={'projection': ccrs.PlateCarree()},
tight_layout=True)
#fig.tight_layout() I get the same result. But with a warning: |
I'm not sure if this is an issue related to matplotlib or cartopy. I'll give an example here, hope somebody will figure this out. With packages of the following, I can still reproduce this:
matplotlib = 1.5.1
cartopy = 0.14.dev0
By running the code in notebook, I got an image shown as

inline
in notebook. I did a screen clipping. The image is as:And the

a.png
file saved byfig.savefig('a.png', dpi=300)
is as:Notice that the first plot of the
a.png
is not the same size as the others, and it isn't aranged well.Something out of the issue:
Of this example, how can I get 3 or 5 (any odd number other than 1) axes? Because now, I have to photoshop the result image to remove the 6th subplot and leave only the legend. If somebody know something, please let me know. Very appreciate.
Please tell me if any more information is needed.
Thanks.
The text was updated successfully, but these errors were encountered: