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

Skip to content

Commit f51642b

Browse files
committed
Clarify docstrings on Subplot classes; closes 1659419
svn path=/trunk/matplotlib/; revision=4665
1 parent 735ffe2 commit f51642b

2 files changed

Lines changed: 18 additions & 34 deletions

File tree

lib/matplotlib/axes.py

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5403,25 +5403,23 @@ def matshow(self, Z, **kwargs):
54035403

54045404
class SubplotBase:
54055405
"""
5406-
Emulate matlab's(TM) subplot command, creating axes with
5407-
5408-
Subplot(numRows, numCols, plotNum)
5409-
5410-
where plotNum=1 is the first plot number and increasing plotNums
5411-
fill rows first. max(plotNum)==numRows*numCols
5412-
5413-
You can leave out the commas if numRows<=numCols<=plotNum<10, as
5414-
in
5415-
5416-
Subplot(211) # 2 rows, 1 column, first (upper) plot
5406+
Base class for subplots, which are Axes instances with additional
5407+
methods to facilitate generating and manipulating a set of Axes
5408+
within a figure.
54175409
"""
54185410

54195411
def __init__(self, fig, *args):
54205412
"""
54215413
fig is a figure instance
54225414
5423-
args is a varargs to specify the subplot
5415+
args is numRows, numCols, plotNum
5416+
where the array of subplots in the figure has dimensions
5417+
numRows, numCols, and where plotNum is the number of the
5418+
subplot being created. plotNum starts at 1 in the upper
5419+
right corner and increases to the right.
54245420
5421+
If numRows<=numCols<=plotNum<10, args can be the decimal
5422+
integer numRows*100 + numCols*10 + plotNum.
54255423
"""
54265424

54275425
self.figure = fig
@@ -5538,24 +5536,17 @@ def label_outer(self):
55385536

55395537
class Subplot(SubplotBase, Axes):
55405538
"""
5541-
Emulate matlab's(TM) subplot command, creating axes with
5542-
5543-
Subplot(numRows, numCols, plotNum)
5544-
5545-
where plotNum=1 is the first plot number and increasing plotNums
5546-
fill rows first. max(plotNum)==numRows*numCols
5539+
subplot class for Cartesian Axes
55475540
5548-
You can leave out the commas if numRows<=numCols<=plotNum<10, as
5549-
in
5550-
5551-
Subplot(211) # 2 rows, 1 column, first (upper) plot
5541+
This is not normally instantiated by the user; instead,
5542+
use the Figure.add_subplot method.
55525543
"""
55535544
def __str__(self):
55545545
return "Subplot(%g,%g)"%(self.bottom.get(),self.left.get())
55555546

55565547
def __init__(self, fig, *args, **kwargs):
55575548
"""
5558-
See Axes base class documentation for args and kwargs
5549+
See SubplotBase and Axes base class documentation for args and kwargs
55595550
"""
55605551
SubplotBase.__init__(self, fig, *args)
55615552
Axes.__init__(self, fig, [self.figLeft, self.figBottom,
@@ -5565,7 +5556,6 @@ def __init__(self, fig, *args, **kwargs):
55655556

55665557
class PolarAxes(Axes):
55675558
"""
5568-
55695559
Make a PolarAxes. The rectangular bounding box of the axes is given by
55705560
55715561
@@ -6018,17 +6008,10 @@ def table(self, *args, **kwargs):
60186008

60196009
class PolarSubplot(SubplotBase, PolarAxes):
60206010
"""
6021-
Create a polar subplot with
6022-
6023-
PolarSubplot(numRows, numCols, plotNum)
6024-
6025-
where plotNum=1 is the first plot number and increasing plotNums
6026-
fill rows first. max(plotNum)==numRows*numCols
6027-
6028-
You can leave out the commas if numRows<=numCols<=plotNum<10, as
6029-
in
6011+
subplot class for Polar Axes
60306012
6031-
Subplot(211) # 2 rows, 1 column, first (upper) plot
6013+
This is not normally instantiated by the user; instead,
6014+
use the Figure.add_subplot(..., polar=True) method.
60326015
"""
60336016
def __str__(self):
60346017
return "PolarSubplot(%gx%g)"%(self.figW,self.figH)

lib/matplotlib/figure.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,7 @@ def add_subplot(self, *args, **kwargs):
519519
Add a subplot. Examples
520520
521521
add_subplot(111)
522+
add_subplot(1,1,1) # equivalent but more general
522523
add_subplot(212, axisbg='r') # add subplot with red background
523524
add_subplot(111, polar=True) # add a polar subplot
524525
add_subplot(sub) # add Subplot instance sub

0 commit comments

Comments
 (0)