Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 200a91a

Browse files
committed
Merge branch 'subplot-without-args' of https://github.com/ivanov/matplotlib
Conflicts: CHANGELOG
2 parents c62a6cc + 31e0a10 commit 200a91a

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
Also added some tests for the normalization class.
33
Till Stensitzki
44

5+
2012-11-09 Make plt.subplot() without arguments act as subplot(111) - PI
6+
57
2012-10-05 Add support for saving animations as animated GIFs. - JVDP
68

79
2012-08-11 Fix path-closing bug in patches.Polygon, so that regardless

doc/users/whats_new.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ Andrew Dawson added a new keyword argument *extendrect* to
2626
:meth:`~matplotlib.pyplot.colorbar` to optionally make colorbar
2727
extensions rectangular instead of triangular.
2828

29+
Calling subplot() without arguments
30+
-----------------------------------
31+
A call to :func:`~matplotlib.pyplot.subplot` without any arguments now
32+
acts the same as `subplot(111)` or `subplot(1,1,1)` -- it creates one axes for
33+
the whole figure. This was already the behavior for both
34+
:func:`~matplotlib.pyplot.axes` and :func:`~matplotlib.pyplot.subplots`, and
35+
now this consistency is shared with :func:`~matplotlib.pyplot.subplot`.
2936

3037
.. _whats-new-1-2:
3138

lib/matplotlib/pyplot.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,9 @@ def subplot(*args, **kwargs):
727727
728728
``subplot(111)`` is the default axis.
729729
730+
``subplot()`` by itself is the same as ``subplot(111)``
731+
732+
730733
New subplots that overlap old will delete the old axes. If you do
731734
not want this behavior, use
732735
:meth:`~matplotlib.figure.Figure.add_subplot` or the
@@ -768,6 +771,10 @@ def subplot(*args, **kwargs):
768771
.. plot:: mpl_examples/pylab_examples/subplot_demo.py
769772
770773
"""
774+
# if subplot called without arguments, create subplot(1,1,1)
775+
if len(args)==0:
776+
args=(1,1,1)
777+
771778
# This check was added because it is very easy to type
772779
# subplot(1, 2, False) when subplots(1, 2, False) was intended
773780
# (sharex=False, that is). In most cases, no error will

0 commit comments

Comments
 (0)