make subplots smarter with regards to subplot_kw and figure_kw

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

Author: Fantashit

2 thoughts on “make subplots smarter with regards to subplot_kw and figure_kw

  1. @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.

Comments are closed.