MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / __init__

Method __init__

site-packages/matplotlib/axes/_subplots.py:18–87  ·  view source on GitHub ↗

*fig* is a :class:`matplotlib.figure.Figure` instance. *args* is the tuple (*numRows*, *numCols*, *plotNum*), where the array of subplots in the figure has dimensions *numRows*, *numCols*, and where *plotNum* is the number of the subplot being created. *plo

(self, fig, *args, **kwargs)

Source from the content-addressed store, hash-verified

16 """
17
18 def __init__(self, fig, *args, **kwargs):
19 """
20 *fig* is a :class:`matplotlib.figure.Figure` instance.
21
22 *args* is the tuple (*numRows*, *numCols*, *plotNum*), where
23 the array of subplots in the figure has dimensions *numRows*,
24 *numCols*, and where *plotNum* is the number of the subplot
25 being created. *plotNum* starts at 1 in the upper left
26 corner and increases to the right.
27
28 If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
29 decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
30 """
31
32 self.figure = fig
33
34 if len(args) == 1:
35 if isinstance(args[0], SubplotSpec):
36 self._subplotspec = args[0]
37 else:
38 try:
39 s = str(int(args[0]))
40 rows, cols, num = map(int, s)
41 except ValueError:
42 raise ValueError('Single argument to subplot must be '
43 'a 3-digit integer')
44 self._subplotspec = GridSpec(rows, cols,
45 figure=self.figure)[num - 1]
46 # num - 1 for converting from MATLAB to python indexing
47 elif len(args) == 3:
48 rows, cols, num = args
49 rows = int(rows)
50 cols = int(cols)
51 if isinstance(num, tuple) and len(num) == 2:
52 num = [int(n) for n in num]
53 self._subplotspec = GridSpec(
54 rows, cols,
55 figure=self.figure)[(num[0] - 1):num[1]]
56 else:
57 if num < 1 or num > rows*cols:
58 raise ValueError(
59 ("num must be 1 <= num <= {maxn}, not {num}"
60 ).format(maxn=rows*cols, num=num))
61 self._subplotspec = GridSpec(
62 rows, cols, figure=self.figure)[int(num) - 1]
63 # num - 1 for converting from MATLAB to python indexing
64 else:
65 raise ValueError('Illegal argument(s) to subplot: %s' % (args,))
66
67 self.update_params()
68
69 # _axes_class is set in the subplot_class_factory
70 self._axes_class.__init__(self, fig, self.figbox, **kwargs)
71 # add a layout box to this, for both the full axis, and the poss
72 # of the axis. We need both because the axes may become smaller
73 # due to parasitic axes and hence no longer fill the subplotspec.
74 if self._subplotspec._layoutbox is None:
75 self._layoutbox = None

Callers

nothing calls this directly

Calls 3

update_paramsMethod · 0.95
GridSpecClass · 0.90
formatMethod · 0.45

Tested by

no test coverage detected