Skip to content
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

make subplots smarter with regards to subplot_kw and figure_kw #1460

Closed
ivanov opened this issue Nov 8, 2012 · 6 comments
Closed

make subplots smarter with regards to subplot_kw and figure_kw #1460

ivanov opened this issue Nov 8, 2012 · 6 comments
Labels
API: changes Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature

Comments

@ivanov
Copy link
Member

ivanov commented Nov 8, 2012

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:

fig = plt.figure(figsize=(10,20))
ax = plt.subplot(111, axisbg='w')

you have to do an awkward thing to subplot's keyword arguments, since, subplot*s* passes its keyword arguments to plt.figure.

fig, ax = plt.subplots(figsize=(10,20), subplot_kw=dict(axisbg='w'))

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:

fig, ax = plt.subplots(figsize=(10,20), axisbg='w')

in our docs, plt.axes takes these kwargs:

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

jarondl pushed a commit to jarondl/matplotlib that referenced this issue Sep 16, 2013
While working on matplotlib#1460, I've found that the `__init__` of `_BaseAxes`
takes some redundant arguments. Of the 7 arguments it takes,
3 (`xscale, yscale, label`) can be removed without harm, because
they are automatically used in `update(kwargs)` (they have matching `set_`
methods). Another two have different names as setters: `frameon` == `frame_on`
and `axisbg` ~ `axis_bgcolor`. Note that the later are mispelled, as they
refer to axes and not axis. The following call is actually legal:

    plt.subplot(111, axisbg='green', axis_bgcolor='red')

I do not know what to do with the other two arguments. (`sharex` `sharey`)

I've tried to remove this redunancy, keeping the old defaults
intact, and without breaking the api. My opinion is that axisbg and frameon
should be reomved, but api changes and deprectations are above my level.

See also issue matplotlib#1460
@tacaswell tacaswell added this to the v1.5.x milestone Aug 17, 2014
@petehuang
Copy link
Contributor

Still looks valid as of 1.5.3. This seems to be an elegance concern, would think about the priority of this.

Relevant:

@tacaswell tacaswell modified the milestones: 2.1 (next point release), 2.2 (next next feature release) Oct 3, 2017
@dstansby dstansby added Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues and removed low hanging fruit labels Jun 1, 2019
@JacobChamberlain
Copy link

Is anyone else currently working on this? If not I'll give it a try.

@jklymak
Copy link
Member

jklymak commented 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
Copy link

@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
Copy link
Member Author

ivanov commented Apr 17, 2020

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?

@anntzer
Copy link
Contributor

anntzer commented Apr 17, 2020

I agree this should be closed.

@anntzer anntzer closed this as completed Apr 17, 2020
@ivanov ivanov modified the milestones: needs sorting, unassigned Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API: changes Difficulty: Easy https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues New feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants