[Matplotlib-devel] Offer of additions to subplots

Christopher Field christophertfield at gmail.com
Sat Apr 30 12:59:36 EDT 2016

	I love pyplot.subplots and use it to create almost all of my graphs. I have implemented code for two subplots enhancements. Because I have never contributed to an open source project, I wanted to clear the additions before I put in the effort to learn how to make a contribution and implement all of the supporting documentation and samples.

	I found that was often writing
Fig, ax = plt.subplots( N, M, squeeze=False )
ax = ax.flatten()         or ax=ax.ravel()
	My addition provides a squeeze=‘flatten’ option, which always returns a 1D numpy array.  This is useful under three situations. First, there is a 2D arrangement of plots that are to be populated by indexing in a single loop. Second, there is a  1D arrangement of plots of variable number which, if squeeze=True, might return a single axis or a numpy array. Third, there is a 2D arrangement of plots that you wish to access with a single subscript.
	Does providing squeeze with bool or string values violate any rules?
	What is the clearest string to use? I have considered ‘flatten’, ‘flat’, ‘ravel’, and ‘1d’.

	The second enhancement permits sharing axis between different figures. It extends the sharex and sharey arguments to accept either an axis instance (in which case all of the new plots share the same x or y limits), or 1D or 2D numpy arrays of axis instances (in which case rows/columns are shared or each plot shares with the corresponding plot passed in.

	Should I invest the effort required to submit these? Is there a time frame in which these additions would be more or less welcome?

Thank you,
Christopher Field

More information about the Matplotlib-devel mailing list