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
Figure linewidth not documented and not visible when saved #9370
When creating a figure it is possible to use linewidth along with edgecolor to create a border around the figure. The linewidth parameter is not shown in the documentation. There is no corresponding set_linewidth figure method.
Also, when saving to a file, this border is missing.
On Wed, Oct 11, 2017 at 11:37 AM, Ted Petrou ***@***.***> wrote:
Bug report
*Bug summary*
When creating a figure it is possible to use linewidth along with
edgecolor to create a border around the figure. The linewidth parameter
is not shown in the documentation
<https://matplotlib.org/api/_as_gen/matplotlib.pyplot.figure.html#matplotlib.pyplot.figure>.
There is no corresponding set_linewidth figure method.
Also, when saving to a file, this border is missing.
I am using Jupyter notebook.
*Code for reproduction*
fig = plt.figure(linewidth=20, edgecolor='r')
plt.plot([5,6])
plt.savefig('/Users/Ted/Desktop/figlw.png')
*Actual outcome*
[image: screen shot 2017-10-11 at 11 32 37 am]
<https://user-images.githubusercontent.com/7226751/31450707-1b68a7a6-ae78-11e7-83cb-e0d57d28abb2.png>
*Expected outcome*
*Matplotlib version*
- Operating system: OSX
- Matplotlib version: 2.1
- Matplotlib backend (module://ipykernel.pylab.backend_inline):
- Python version: 2.6
- Jupyter version (if applicable): 5.0
- Other libraries:
Updated through conda
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9370>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-AKdaRf5qieCcDHjBmAMX6mXk3Weks5srOC-gaJpZM4P1sMW>
.
I can confirm this as the behaviour. plt.show() has the nice red box, printing does not.
It is documented, at least on master in the Figure class:
def__init__(self,
figsize=None, # defaults to rc figure.figsizedpi=None, # defaults to rc figure.dpifacecolor=None, # defaults to rc figure.facecoloredgecolor=None, # defaults to rc figure.edgecolorlinewidth=0.0, # the default linewidth of the frameframeon=None, # whether or not to draw the figure framesubplotpars=None, # default to rctight_layout=None, # default to rc figure.autolayout
):
"""
*figsize*w,htupleininches*dpi*Dotsperinch*facecolor*Thefigurepatchfacecolor; defaultstorc``figure.facecolor``*edgecolor*Thefigurepatchedgecolor; defaultstorc``figure.edgecolor``*linewidth*Thefigurepatchedgelinewidth; thedefaultlinewidthoftheframe
no idea why its not rendering when a png is saved...
Huh... I stand corrected. I just never figured that was a thing. I learn
something new all the time.
If this is happening only in the inline backend, then this is a bug on
ipython/jupyter's part, not ours. They maintain that backend.
Well. It's still an issue for us because using e.g. qt5agg you get the same discrepancy.
This is because the figure edgecolor is overridden by the savefig.edgecolor rcParam at save time. Setting rcParams["savefig.edgecolor"] = "r" fixes the issue for qt5agg (I can see why this rcParam (or rather its companion, rcParams["savefig.facecolor"]) used to exist back when the UI interface defaulted to a gray background but you'd want to save figures with a white background, but as usual these days it seems to be more a pain point than anything and I'd suggest either deprecating them or at least switching the default from "w" to something that says "don't touch it").
But even setting savefig.edgecolor doesn't fix it for jupyter inline mode.
Also I think the relevant setter method lives on plt.gcf().patch (a Rectangle object).
Activity
WeatherGod commentedon Oct 11, 2017
jklymak commentedon Oct 11, 2017
I can confirm this as the behaviour.
plt.show()has the nice red box, printing does not.It is documented, at least on master in the Figure class:
no idea why its not rendering when a png is saved...
tdpetrou commentedon Oct 11, 2017
Ok,now I'm confused. I see it documented here at matplotlib.figure.Figure
anntzer commentedon Oct 11, 2017
fwiw, only occurs in notebook inline backend, not notebook backend
WeatherGod commentedon Oct 11, 2017
anntzer commentedon Oct 11, 2017
Well. It's still an issue for us because using e.g. qt5agg you get the same discrepancy.
This is because the figure edgecolor is overridden by the
savefig.edgecolorrcParam at save time. SettingrcParams["savefig.edgecolor"] = "r"fixes the issue for qt5agg (I can see why this rcParam (or rather its companion, rcParams["savefig.facecolor"]) used to exist back when the UI interface defaulted to a gray background but you'd want to save figures with a white background, but as usual these days it seems to be more a pain point than anything and I'd suggest either deprecating them or at least switching the default from "w" to something that says "don't touch it").But even setting savefig.edgecolor doesn't fix it for jupyter inline mode.
Also I think the relevant setter method lives on
plt.gcf().patch(a Rectangle object).jklymak commentedon Oct 11, 2017
I reproduced in
MacOSXbackend.QuLogic commentedon Jun 3, 2021
I believe this is fixed by #15111.