Offer of additions to subplots

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

We have a number of other cases where we mix types on input. I have also
wanted `squeeze='flatten'` on a few occasions and am +1 on the first idea

I am a bit more hesitant on the second, it might be crossing the line into
making the API too clever/flexible for its own good.

Tom

···

On Mon, May 16, 2016 at 2:06 PM Christopher Field < christophertfield at gmail.com> wrote:

        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

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel at python.org
https://mail.python.org/mailman/listinfo/matplotlib-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20160516/c0f6297f/attachment.html>

I'm +1 on the addition of `squeeze='flatten'` as well. As a matter of fact
I found 5 instances of `axes = axes.flatten()` I've written in the past six
months, and even more cases where I didn't think of flatten() and used a
combination of floor division and modulus to achieve 2D indeces.

With regard two axis sharing, can you expand on the API you are proposing?
There seems to be some functionality for this as answered on StackOverflow
<http://stackoverflow.com/questions/4200586/matplotlib-pyplot-how-to-zoom-subplots-together>
.

I am a bit more hesitant on the second, it might be crossing the line

into making the API too clever/flexible for its own good.
I'd have to look at the code to agree/disagree with you; but I wouldn't be
surprised if somewhere along the line someone made the assumption that axes
would only be owned by a single figure/subplot. Christopher, do all the
unit tests pass with this patch?

Overall, axis sharing sounds a lot like linkaxes() in Matlab
<http://www.mathworks.com/help/matlab/ref/linkaxes.html>. If axis *sharing*
doesn't work, maybe axis *synchronization* could.

Daniel

···

On Mon, May 16, 2016 at 2:54 PM Thomas Caswell <tcaswell at gmail.com> wrote:

We have a number of other cases where we mix types on input. I have also
wanted `squeeze='flatten'` on a few occasions and am +1 on the first idea

I am a bit more hesitant on the second, it might be crossing the line into
making the API too clever/flexible for its own good.

Tom

On Mon, May 16, 2016 at 2:06 PM Christopher Field < > christophertfield at gmail.com> wrote:

        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

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel at python.org
https://mail.python.org/mailman/listinfo/matplotlib-devel

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel at python.org
https://mail.python.org/mailman/listinfo/matplotlib-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20160520/69122cd0/attachment.html>

Yes, matlab's linkaxes() is the same as our axis sharing. I would be
hesitant to create a new and similar concept of "synchronization", though.

···

On Fri, May 20, 2016 at 5:06 PM, Daniel da Silva <mail at danieldasilva.org> wrote:

I'm +1 on the addition of `squeeze='flatten'` as well. As a matter of fact
I found 5 instances of `axes = axes.flatten()` I've written in the past six
months, and even more cases where I didn't think of flatten() and used a
combination of floor division and modulus to achieve 2D indeces.

With regard two axis sharing, can you expand on the API you are proposing?
There seems to be some functionality for this as answered on StackOverflow
<http://stackoverflow.com/questions/4200586/matplotlib-pyplot-how-to-zoom-subplots-together>
.

> I am a bit more hesitant on the second, it might be crossing the line
into making the API too clever/flexible for its own good.
I'd have to look at the code to agree/disagree with you; but I wouldn't be
surprised if somewhere along the line someone made the assumption that axes
would only be owned by a single figure/subplot. Christopher, do all the
unit tests pass with this patch?

Overall, axis sharing sounds a lot like linkaxes() in Matlab
<http://www.mathworks.com/help/matlab/ref/linkaxes.html>. If axis
*sharing* doesn't work, maybe axis *synchronization* could.

Daniel

On Mon, May 16, 2016 at 2:54 PM Thomas Caswell <tcaswell at gmail.com> wrote:

We have a number of other cases where we mix types on input. I have also
wanted `squeeze='flatten'` on a few occasions and am +1 on the first idea

I am a bit more hesitant on the second, it might be crossing the line
into making the API too clever/flexible for its own good.

Tom

On Mon, May 16, 2016 at 2:06 PM Christopher Field < >> christophertfield at gmail.com> wrote:

        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

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel at python.org
https://mail.python.org/mailman/listinfo/matplotlib-devel

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel at python.org
https://mail.python.org/mailman/listinfo/matplotlib-devel

_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel at python.org
https://mail.python.org/mailman/listinfo/matplotlib-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20160523/13834721/attachment.html>