diff --git a/CHANGELOG b/CHANGELOG index 1124187a8d84..37159d5941d7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +2012-11-09 Make plt.subplot() without arguments act as subplot(111) - PI + 2012-10-05 Add support for saving animations as animated GIFs. - JVDP 2012-08-11 Fix path-closing bug in patches.Polygon, so that regardless diff --git a/doc/users/whats_new.rst b/doc/users/whats_new.rst index ce2fd09c57e3..d09c6732af14 100644 --- a/doc/users/whats_new.rst +++ b/doc/users/whats_new.rst @@ -26,6 +26,13 @@ Andrew Dawson added a new keyword argument *extendrect* to :meth:`~matplotlib.pyplot.colorbar` to optionally make colorbar extensions rectangular instead of triangular. +Calling subplot() without arguments +----------------------------------- +A call to :func:`~matplotlib.pyplot.subplot` without any arguments now +acts the same as `subplot(111)` or `subplot(1,1,1)` -- it creates one axes for +the whole figure. This was already the behavior for both +:func:`~matplotlib.pyplot.axes` and :func:`~matplotlib.pyplot.subplots`, and +now this consistency is shared with :func:`~matplotlib.pyplot.subplot`. .. _whats-new-1-2: diff --git a/lib/matplotlib/pyplot.py b/lib/matplotlib/pyplot.py index 997382e47d44..4dd2f44504ba 100644 --- a/lib/matplotlib/pyplot.py +++ b/lib/matplotlib/pyplot.py @@ -727,6 +727,9 @@ def subplot(*args, **kwargs): ``subplot(111)`` is the default axis. + ``subplot()`` by itself is the same as ``subplot(111)`` + + New subplots that overlap old will delete the old axes. If you do not want this behavior, use :meth:`~matplotlib.figure.Figure.add_subplot` or the @@ -768,6 +771,10 @@ def subplot(*args, **kwargs): .. plot:: mpl_examples/pylab_examples/subplot_demo.py """ + # if subplot called without arguments, create subplot(1,1,1) + if len(args)==0: + args=(1,1,1) + # This check was added because it is very easy to type # subplot(1, 2, False) when subplots(1, 2, False) was intended # (sharex=False, that is). In most cases, no error will