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
I have some feature requests and/or questions about the grid behaviors in matplotlib v2.0+:
(1) Is it possible to set the default grid line to even lighter gray, and even thinner line width? Just like the style in MATLAB? The current new Matplotlib defaults generate grid lines that look too pronounced.
In fact, when using Matplotlib 2.0+, I always use plt.grid(ls=':') instead of just plt.grid(). It looks much better.
(2) The zorder behavior, if set to None, is undefined, or at least not documented clearly.
For example, I tried the following codes respectively:
There is indeed some needs to pass None to zorder, especially when designing wrapper functions where zorder sometimes needs to be specified by the user, and sometimes doesn't.
Non-numeric zorder errors out on Py3 because they can't, well, be compared with numbers.
On Py2 None is sorted before numbers hence the observed behavior. I honestly don't care enough about Py2 anymore to fix that...
@anntzer wasn't saying not to fix it. He was saying he wasn't going to fix it. I'm sure a sensible PR would be welcome. But I think the point is that zorder=None is undefined, so don't do that.
I guess there is some need to update the documentation containing zorder, adding a note for Python 2 users in the documentation. Or Matplotlib can raise a warning message when Python 2 users try to set zorder=None
The general rule in matplotlib is that "*None* means do the default thing".
So, I agree that not specifying zorder and specifying zorder=None should be
equivalent.
On Wed, Nov 15, 2017 at 1:13 PM, Jian Shi ***@***.***> wrote:
I guess there is some need to update the documentation containing zorder,
adding a note for Python 2 users in the documentation. Or Matplotlib can
raise a warning message when Python 2 users try to set zorder=None
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9785 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-FhtgvQUPira4naiCP1jlUK0dJcAks5s2yncgaJpZM4QeHt9>
.
We are committed to python2 support through mpl2.2 (early next year) and bug fixes on that branch until 2020. The level of back-ported support to 2.2.x will depend on volunteer interest, but I am personally committed to does-not-import / segfault type bug fixes.
That said, this is not a python2/python3 bug, the issue is that zorder=None is not being properly handled in any version. It should, as @WeatherGod says, mean 'do the default thing' as the OP expected.
Yes, I am aware of rcparams or style sheets, but it is somewhat cumbersome (for example, I have to revert the styles back for other users of my scripts, because I don't want to mess up their flavor of plotting styles).
The reason I'm bring this issue up is that I think the Matplotlib default style leaves some aesthetic room to be desired. And making the default style more pleasing can attract more potential users. (Of course, this is a somewhat subjective discussion, and I am open to hearing other people's opinion about this :-)
I think thats why there are style files - so you can set the grid however you want. The default styles were just changed for 2.0, presumably to someone's aesthetic delight. So my guess is that they won't be reconsidered again for a while.
@jklymak Well I think that @tacaswell is used to target “the right branch” for his PRs ^^. For example, #9793 was not merged on the master branch, so this might be the explanation.
Activity
anntzer commentedon Nov 14, 2017
xref #9094 re: zorder.
jsh9 commentedon Nov 14, 2017
I tried this:
plt.figure(); ax=plt.axes(); plt.plot([0,1],[0,1],lw=10,zorder=None); plt.grid(); ax.set_axisbelow(True);But the line is still below the grids. Apparently
zorder=Nonewithinplt.plot()sends the line to the most bottom layer...Shouldn't
zorder=Nonewithinplt.plot()just work as if we did not invoke this argument at all?anntzer commentedon Nov 14, 2017
Non-numeric zorder errors out on Py3 because they can't, well, be compared with numbers.
On Py2 None is sorted before numbers hence the observed behavior. I honestly don't care enough about Py2 anymore to fix that...
ImportanceOfBeingErnest commentedon Nov 15, 2017
@anntzer I really hope you do care about python 2 still. According to this statics

it is still used more than python 3. Also see here.
So there should be a defined behaviour of
zorder=None, independent on the version of python in use. Why not simply throw an error as well?jklymak commentedon Nov 15, 2017
@anntzer wasn't saying not to fix it. He was saying he wasn't going to fix it. I'm sure a sensible PR would be welcome. But I think the point is that
zorder=Noneis undefined, so don't do that.jsh9 commentedon Nov 15, 2017
I guess there is some need to update the documentation containing
zorder, adding a note for Python 2 users in the documentation. Or Matplotlib can raise a warning message when Python 2 users try to setzorder=NoneWeatherGod commentedon Nov 15, 2017
anntzer commentedon Nov 15, 2017
To be clear: I will obviously not prevent anyone from fixing the issue on py2.
tacaswell commentedon Nov 15, 2017
We are committed to python2 support through mpl2.2 (early next year) and bug fixes on that branch until 2020. The level of back-ported support to 2.2.x will depend on volunteer interest, but I am personally committed to does-not-import / segfault type bug fixes.
That said, this is not a python2/python3 bug, the issue is that
zorder=Noneis not being properly handled in any version. It should, as @WeatherGod says, mean 'do the default thing' as the OP expected.@jsh9 You can use rcparams / style sheets to set the default gridline style and color https://matplotlib.org/users/customizing.html
jsh9 commentedon Nov 15, 2017
@tacaswell Thanks for the comments.
Yes, I am aware of rcparams or style sheets, but it is somewhat cumbersome (for example, I have to revert the styles back for other users of my scripts, because I don't want to mess up their flavor of plotting styles).
The reason I'm bring this issue up is that I think the Matplotlib default style leaves some aesthetic room to be desired. And making the default style more pleasing can attract more potential users. (Of course, this is a somewhat subjective discussion, and I am open to hearing other people's opinion about this :-)
jklymak commentedon Nov 15, 2017
I think thats why there are style files - so you can set the grid however you want. The default styles were just changed for 2.0, presumably to someone's aesthetic delight. So my guess is that they won't be reconsidered again for a while.
[-]Default grid behaviors in matplotlib v2.0+[/-][+]`plt.grid` does not handle `zorder=None` properly[/+]tacaswell commentedon Nov 15, 2017
The style context managers can be helpful for ensure the style gets reverted.
Changed the issue title to better reflect the bug that needs to be fixed.
jsh9 commentedon Nov 15, 2017
Not only
plt.griddoes not handlezorder=Noneproperly, but alsoplt.plotand maybe other functions, am I correct?tacaswell commentedon Nov 16, 2017
@jsh9 🐑 did not read carefully enough or test
[-]`plt.grid` does not handle `zorder=None` properly[/-][+] `zorder=None` not properly handled[/+]FIX: treat `zorder=None` as falling back to the default
afvincent commentedon Nov 17, 2017
@tacaswell Should this issue be closed since #9793 was merged?
tacaswell commentedon Nov 17, 2017
It will auto-close when the merge up to master happens
jklymak commentedon Nov 17, 2017
But isn't #9793 merged already? I'll close, and re-open if you meant something else...
afvincent commentedon Nov 17, 2017
@jklymak Well I think that @tacaswell is used to target “the right branch” for his PRs ^^. For example, #9793 was not merged on the master branch, so this might be the explanation.
jklymak commentedon Nov 17, 2017
Ohhhh. I see. He merged it into 2.1.x. My mistake...