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
make subplots smarter with regards to subplot_kw and figure_kw #1460
While working on #1458, it occurred to me that it might not be a bad idea to process the keyword arguments given to plt.subplots and pass them along in the appropriate direction. As I alluded to in #1458, currently, to replace lines like:
but, at least as I was going through our examples, all of the subplot keyword arguments were pretty unambiguously named, and could not be interpreted as figure keyword arguments. So there's no reason why we shouldn't make the next line work the same as the two examples above:
axisbg color the axes background color
frameon [True|False] display the frame?
sharex otherax current axes shares xaxis attribute with otherax
sharey otherax current axes shares yaxis attribute with otherax
polar [True|False] use a polar axes?
and plt.subplot says it deals with axisbg, polar, and projection
@JacobChamberlain sure, but be prepared for some discussion as to whether this is a good idea. I tend to think it is a good idea, because those kwarg dictionaries are pretty ugly and hard for users to grok, but there may be subtleties I'm not aware of.
@jklymak We suspect we may run into some issue. I'll let you know what issues we find, but those dictionaries are pretty ugly so any clean up is an improvement in my book.
Reacted by Jody Klymak, Saba and Angela Zavaleta Bernuy
At the time I created this issue (seven and a half years ago), subplots had "only" been around for two years (in matplotlib proper, anyway), thus somewhat new, and certainly underutilized, to the point where none of our examples were using it, which meant that many of our users were unaware of it. The proposal was to make it easier for folks to transition to using it, in particular since a lot of our examples used the pattern of
figure()
subplot(111, axisbg='w')
which using subplots (then and in its current form) could become
plt.subplots(subplot_kw=dict(axisbg='w'))
and was not necessarily better. Since subplot (singular) forwarded its keyword arguments to plt.axes, which back then were documented as axisbg, frameon, sharex, sharey, and polar, and given that sharex and sharey already were part of the subplots (plural) keywords (though now accepting boolean values), I thought it might be ergonomic to make those arguments pass directly from subplots' kwargs (or make them all into top level keyword arguments, even).
Now that it's been another seven and half years later, it probably no longer makes sense to make the advertised keyword arguments of subplot (singular) available directly in subplots without relegating them to the subplot_kw keyword argument.
Unless I'm misreading the conversation between @sabulikia, @QuLogic , and @tacaswell over in #16738, it seems like we should close this issue?
Activity
remove some redunancy in _BaseAxes
petehuang commentedon Dec 31, 2016
Still looks valid as of 1.5.3. This seems to be an elegance concern, would think about the priority of this.
Relevant:
JacobChamberlain commentedon Mar 3, 2020
Is anyone else currently working on this? If not I'll give it a try.
jklymak commentedon Mar 3, 2020
@JacobChamberlain sure, but be prepared for some discussion as to whether this is a good idea. I tend to think it is a good idea, because those kwarg dictionaries are pretty ugly and hard for users to grok, but there may be subtleties I'm not aware of.
JacobChamberlain commentedon Mar 3, 2020
@jklymak We suspect we may run into some issue. I'll let you know what issues we find, but those dictionaries are pretty ugly so any clean up is an improvement in my book.
ivanov commentedon Apr 17, 2020
At the time I created this issue (seven and a half years ago),
subplotshad "only" been around for two years (in matplotlib proper, anyway), thus somewhat new, and certainly underutilized, to the point where none of our examples were using it, which meant that many of our users were unaware of it. The proposal was to make it easier for folks to transition to using it, in particular since a lot of our examples used the pattern ofwhich using subplots (then and in its current form) could become
and was not necessarily better. Since
subplot(singular) forwarded its keyword arguments toplt.axes, which back then were documented asaxisbg,frameon,sharex,sharey, andpolar, and given thatsharexandshareyalready were part of thesubplots(plural) keywords (though now accepting boolean values), I thought it might be ergonomic to make those arguments pass directly from subplots' kwargs (or make them all into top level keyword arguments, even).Now that it's been another seven and half years later, it probably no longer makes sense to make the advertised keyword arguments of
subplot(singular) available directly insubplotswithout relegating them to thesubplot_kwkeyword argument.Unless I'm misreading the conversation between @sabulikia, @QuLogic , and @tacaswell over in #16738, it seems like we should close this issue?
anntzer commentedon Apr 17, 2020
I agree this should be closed.