本文整理汇总了Python中matplotlib.gridspec.SubplotSpec方法的典型用法代码示例。如果您正苦于以下问题:Python gridspec.SubplotSpec方法的具体用法?Python gridspec.SubplotSpec怎么用?Python gridspec.SubplotSpec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.gridspec
的用法示例。
在下文中一共展示了gridspec.SubplotSpec方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_subplotspec
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def get_subplotspec(self):
'get the SubplotSpec instance'
return self._subplotspec
示例2: set_subplotspec
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def set_subplotspec(self, subplotspec):
'set the SubplotSpec instance'
self._subplotspec = subplotspec
示例3: get_subplotspec
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def get_subplotspec(self):
"""get the SubplotSpec instance associated with the subplot"""
return self._subplotspec
示例4: set_subplotspec
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def set_subplotspec(self, subplotspec):
"""set the SubplotSpec instance associated with the subplot"""
self._subplotspec = subplotspec
示例5: get_ax
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def get_ax(ax, show=None, figsize=None, dpi=None, projection=None):
figsize, _ = get_figure_params(figsize)
if ax is None:
projection = "3d" if projection == "3d" else None
ax = pl.figure(None, figsize, dpi=dpi).gca(projection=projection)
elif isinstance(ax, SubplotSpec):
geo = ax.get_geometry()
if show is None:
show = geo[-1] + 1 == geo[0] * geo[1]
ax = pl.subplot(ax)
return ax, show
示例6: __init__
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def __init__(self, fig, *args, **kwargs):
"""
*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. *plotNum* starts at 1 in the upper left
corner and increases to the right.
If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
"""
self.figure = fig
if len(args) == 1:
if isinstance(args[0], SubplotSpec):
self._subplotspec = args[0]
else:
try:
s = str(int(args[0]))
rows, cols, num = list(map(int, s))
except ValueError:
raise ValueError(
'Single argument to subplot must be a 3-digit '
'integer')
self._subplotspec = GridSpec(rows, cols)[num - 1]
# num - 1 for converting from MATLAB to python indexing
elif len(args) == 3:
rows, cols, num = args
rows = int(rows)
cols = int(cols)
if isinstance(num, tuple) and len(num) == 2:
num = [int(n) for n in num]
self._subplotspec = GridSpec(rows, cols)[num[0] - 1:num[1]]
else:
if num < 0 or num > rows*cols:
raise ValueError(
"num must be 0 <= num <= {maxn}, not {num}".format(
maxn=rows*cols, num=num))
if num == 0:
warnings.warn("The use of 0 (which ends up being the "
"_last_ sub-plot) is deprecated in 1.4 "
"and will raise an error in 1.5",
mplDeprecation)
self._subplotspec = GridSpec(rows, cols)[int(num) - 1]
# num - 1 for converting from MATLAB to python indexing
else:
raise ValueError('Illegal argument(s) to subplot: %s' % (args,))
self.update_params()
# _axes_class is set in the subplot_class_factory
self._axes_class.__init__(self, fig, self.figbox, **kwargs)
示例7: __init__
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def __init__(self, fig, *args, horizontal=None, vertical=None,
aspect=None, anchor='C'):
"""
Parameters
----------
fig : :class:`matplotlib.figure.Figure`
args : tuple (*numRows*, *numCols*, *plotNum*)
The array of subplots in the figure has dimensions *numRows*,
*numCols*, and *plotNum* is the number of the subplot
being created. *plotNum* starts at 1 in the upper left
corner and increases to the right.
If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
"""
self.figure = fig
if len(args) == 1:
if isinstance(args[0], SubplotSpec):
self._subplotspec = args[0]
else:
try:
s = str(int(args[0]))
rows, cols, num = map(int, s)
except ValueError:
raise ValueError(
'Single argument to subplot must be a 3-digit integer')
self._subplotspec = GridSpec(rows, cols)[num-1]
# num - 1 for converting from MATLAB to python indexing
elif len(args) == 3:
rows, cols, num = args
rows = int(rows)
cols = int(cols)
if isinstance(num, tuple) and len(num) == 2:
num = [int(n) for n in num]
self._subplotspec = GridSpec(rows, cols)[num[0]-1:num[1]]
else:
self._subplotspec = GridSpec(rows, cols)[int(num)-1]
# num - 1 for converting from MATLAB to python indexing
else:
raise ValueError('Illegal argument(s) to subplot: %s' % (args,))
# total = rows*cols
# num -= 1 # convert from matlab to python indexing
# # i.e., num in range(0,total)
# if num >= total:
# raise ValueError( 'Subplot number exceeds total subplots')
# self._rows = rows
# self._cols = cols
# self._num = num
# self.update_params()
# sets self.fixbox
self.update_params()
pos = self.figbox.bounds
Divider.__init__(self, fig, pos, horizontal or [], vertical or [],
aspect=aspect, anchor=anchor)
示例8: __init__
# 需要导入模块: from matplotlib import gridspec [as 别名]
# 或者: from matplotlib.gridspec import SubplotSpec [as 别名]
def __init__(self, fig, *args, horizontal=None, vertical=None,
aspect=None, anchor='C'):
"""
Parameters
----------
fig : :class:`matplotlib.figure.Figure`
*args : tuple (*numRows*, *numCols*, *plotNum*)
The array of subplots in the figure has dimensions *numRows*,
*numCols*, and *plotNum* is the number of the subplot
being created. *plotNum* starts at 1 in the upper left
corner and increases to the right.
If *numRows* <= *numCols* <= *plotNum* < 10, *args* can be the
decimal integer *numRows* * 100 + *numCols* * 10 + *plotNum*.
"""
self.figure = fig
if len(args) == 1:
if isinstance(args[0], SubplotSpec):
self._subplotspec = args[0]
else:
try:
s = str(int(args[0]))
rows, cols, num = map(int, s)
except ValueError:
raise ValueError(
'Single argument to subplot must be a 3-digit integer')
self._subplotspec = GridSpec(rows, cols)[num-1]
# num - 1 for converting from MATLAB to python indexing
elif len(args) == 3:
rows, cols, num = args
rows = int(rows)
cols = int(cols)
if isinstance(num, tuple) and len(num) == 2:
num = [int(n) for n in num]
self._subplotspec = GridSpec(rows, cols)[num[0]-1:num[1]]
else:
self._subplotspec = GridSpec(rows, cols)[int(num)-1]
# num - 1 for converting from MATLAB to python indexing
else:
raise ValueError(f'Illegal argument(s) to subplot: {args}')
# total = rows*cols
# num -= 1 # convert from matlab to python indexing
# # i.e., num in range(0,total)
# if num >= total:
# raise ValueError( 'Subplot number exceeds total subplots')
# self._rows = rows
# self._cols = cols
# self._num = num
# self.update_params()
# sets self.fixbox
self.update_params()
pos = self.figbox.bounds
Divider.__init__(self, fig, pos, horizontal or [], vertical or [],
aspect=aspect, anchor=anchor)