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
BUG : raise exception in subplot if num out of range #3167
Conversation
Cool, thanks for being so responsive! |
@tacaswell - this has the potential to break a whole lot of code. Before, the following code would "work" by putting an axes on the bottom right (not the top left as one might expect):
The fix is sound, and the existing behaviour is undesirable, but it is potentially problematic for future version adoption... |
@pelson Some how I missed that consequence when I wrote this. I will change this to raise a warning for 0 and claim we will turn it into an exception in 1.5 |
Devil's Advocate: why should negative values be bad? we do negative Answering my own question... because negative indices make no sense in On Mon, Jun 30, 2014 at 11:16 AM, Thomas A Caswell <notifications@github.com
|
@pelson updated |
Good move. I would not expect that even the original version would break code, given that the indexing in subplot has always followed the original Matlab convention, so zero has never been a valid value; but there certainly is no harm in using the intermediate deprecation. |
@@ -177,6 +177,18 @@ original location: | |||
treated as numpy fancy indexing and only the two markers corresponding to the | |||
given indexes will be shown. | |||
|
|||
* The use of the index 0 has in `plt.subplot` and related commands is |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
grammar check please... I think you were trying for "as in", not "has in".
if subplot(rows, cols, num) is called with num not in 0 < num <= rows * cols raise a ValueError close matplotlib#3166
fixed and rebased |
position. This is due to the indexing in subplot being 1-based (to | ||
mirror MATLAB) so before indexing into the `GridSpec` object used to | ||
determine where the axes should go, 1 is subtracted off. Passing in | ||
0 results is passing -1 to `GridSpec` which results in getting the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0 results *in* passing...
fixed and amended. |
BUG : raise exception in subplot if num out of range
if subplot(rows, cols, num) is called with num not in
0 < num <= rows * cols raise a ValueError
close #3166