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

figure.add_subplot(1311): ValueError: Illegal argument(s) to subplot: (1, 3, 1, 1) #2098

Closed
mmokrejs opened this issue May 31, 2013 · 4 comments · Fixed by #2780
Closed

figure.add_subplot(1311): ValueError: Illegal argument(s) to subplot: (1, 3, 1, 1) #2098

mmokrejs opened this issue May 31, 2013 · 4 comments · Fixed by #2780
Milestone

Comments

@mmokrejs
Copy link

I did call _figure.add_subplot(1311) which breaks:

_ax1 = _figure.add_subplot(_ax1_num)

File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 889, in add_subplot
a = subplot_class_factory(projection_class)(self, _args, *_kwargs)
File "/usr/lib64/python2.7/site-packages/matplotlib/axes.py", line 8987, in init
raise ValueError('Illegal argument(s) to subplot: %s' % (args,))
ValueError: Illegal argument(s) to subplot: (1, 3, 1, 1)

Looks max height of the figure can be 9, that is subfigures will be 911, 912, 913, etc. Looks at least a check that the number is less than 999 would be meaningful. Ideally, something more clever like a REGEXP.

Happens on mpl-1.2.1.

@pelson
Copy link
Member

pelson commented May 31, 2013

The documentation for subplot (http://matplotlib.org/api/pyplot_api.html?highlight=subplot#matplotlib.pyplot.subplot) does state that the maximum number of rows/columns/plot_number is 9. The problem is that anything other than three digits is ill-defined. The solution is to use the better approach of plt.subplot(13, 1, 1).

Closing as this is a wontfix, and the documentation is already pretty good.

Cheers,

@pelson pelson closed this as completed May 31, 2013
@mmokrejs
Copy link
Author

Hi Phil,
thanks for a quick answer. It is good it is documented but I proposed a runtime check and asked for a meaningful error message. Even better if it can say that plt.subplot() supports more subfigures due to better API. This is exactly where mpl would benefit from better error messages. But do what you want otherwise. For me dynamically enlarging number of subfigures works fine until 91x and above 9 will later on enslave the plt.subplot() way.

@mdboom
Copy link
Member

mdboom commented May 31, 2013

Yeah -- I tend to agree that a better error message would be nice here. Yet another way to help encourage people to use the multi-argument form...

@mdboom mdboom reopened this May 31, 2013
@tacaswell
Copy link
Member

flagged so this gets an improved error message.

tacaswell added a commit to tacaswell/matplotlib that referenced this issue Feb 1, 2014
Closes matplotlib#2098

If user passes in a not-three-digit integer, raise `ValueError`
instead of letting the error propagate up from much farther down
the stack
tacaswell added a commit to tacaswell/matplotlib that referenced this issue Feb 2, 2014
Closes matplotlib#2098

If user passes in a not-three-digit integer, raise `ValueError`
instead of letting the error propagate up from much farther down
the stack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants