本文整理汇总了Python中matplotlib.pyplot.get_fignums方法的典型用法代码示例。如果您正苦于以下问题:Python pyplot.get_fignums方法的具体用法?Python pyplot.get_fignums怎么用?Python pyplot.get_fignums使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.get_fignums方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_series
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def plot_series(data, kind='line', ax=None, # Series unique
figsize=None, use_index=True, title=None, grid=None,
legend=False, style=None, logx=False, logy=False, loglog=False,
xticks=None, yticks=None, xlim=None, ylim=None,
rot=None, fontsize=None, colormap=None, table=False,
yerr=None, xerr=None,
label=None, secondary_y=False, # Series unique
**kwds):
import matplotlib.pyplot as plt
if ax is None and len(plt.get_fignums()) > 0:
ax = _gca()
ax = MPLPlot._get_ax_layer(ax)
return _plot(data, kind=kind, ax=ax,
figsize=figsize, use_index=use_index, title=title,
grid=grid, legend=legend,
style=style, logx=logx, logy=logy, loglog=loglog,
xticks=xticks, yticks=yticks, xlim=xlim, ylim=ylim,
rot=rot, fontsize=fontsize, colormap=colormap, table=table,
yerr=yerr, xerr=xerr,
label=label, secondary_y=secondary_y,
**kwds)
示例2: test_figure_label
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def test_figure_label():
# pyplot figure creation, selection and closing with figure label and
# number
plt.close('all')
plt.figure('today')
plt.figure(3)
plt.figure('tomorrow')
plt.figure()
plt.figure(0)
plt.figure(1)
plt.figure(3)
assert_equal(plt.get_fignums(), [0, 1, 3, 4, 5])
assert_equal(plt.get_figlabels(), ['', 'today', '', 'tomorrow', ''])
plt.close(10)
plt.close()
plt.close(5)
plt.close('tomorrow')
assert_equal(plt.get_fignums(), [0, 1])
assert_equal(plt.get_figlabels(), ['', 'today'])
示例3: compare
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def compare(self, idx, baseline, extension):
__tracebackhide__ = True
fignum = plt.get_fignums()[idx]
fig = plt.figure(fignum)
if self.remove_text:
remove_ticks_and_titles(fig)
actual_fname = (
os.path.join(self.result_dir, baseline) + '.' + extension)
kwargs = self.savefig_kwargs.copy()
if extension == 'pdf':
kwargs.setdefault('metadata',
{'Creator': None, 'Producer': None,
'CreationDate': None})
fig.savefig(actual_fname, **kwargs)
expected_fname = self.copy_baseline(baseline, extension)
_raise_on_image_difference(expected_fname, actual_fname, self.tol)
示例4: test_figure_label
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def test_figure_label():
# pyplot figure creation, selection and closing with figure label and
# number
plt.close('all')
plt.figure('today')
plt.figure(3)
plt.figure('tomorrow')
plt.figure()
plt.figure(0)
plt.figure(1)
plt.figure(3)
assert plt.get_fignums() == [0, 1, 3, 4, 5]
assert plt.get_figlabels() == ['', 'today', '', 'tomorrow', '']
plt.close(10)
plt.close()
plt.close(5)
plt.close('tomorrow')
assert plt.get_fignums() == [0, 1]
assert plt.get_figlabels() == ['', 'today']
示例5: _showPlot
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def _showPlot(self): # pragma: no cover
# internal, do not use
try:
plt.plot()
if sys.platform.startswith('win'):
plt.show()
else:
plt.draw()
while True:
if plt.get_fignums():
plt.pause(0.001)
else:
break
except KeyboardInterrupt:
plt.close()
示例6: animation_compare
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def animation_compare(baseline_images, nframes, fmt='.png', tol=1e-3, remove_text=True):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
# First close anything from previous tests
plt.close('all')
anim = func(*args, **kwargs)
if remove_text:
fignum = plt.get_fignums()[0]
fig = plt.figure(fignum)
remove_ticks_and_titles(fig)
try:
_compare_animation(anim, baseline_images, fmt, nframes, tol)
finally:
plt.close('all')
return wrapper
return decorator
示例7: close
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def close(fignum=None):
from matplotlib.pyplot import get_fignums, close as _close
if fignum is None:
for fignum in get_fignums():
_close(fignum)
else:
_close(fignum)
# -----------------------------------------------------------------------------
# locale utilities
示例8: close
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def close(fignum=None): # pragma: no cover
from matplotlib.pyplot import get_fignums, close as _close
if fignum is None:
for fignum in get_fignums():
_close(fignum)
else:
_close(fignum)
示例9: cleanup
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def cleanup():
for fig in map(plt.figure, plt.get_fignums()):
fig.clf()
示例10: _alpha_mpl_scraper
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def _alpha_mpl_scraper(block, block_vars, gallery_conf):
import matplotlib.pyplot as plt
image_path_iterator = block_vars['image_path_iterator']
image_paths = list()
for fig_num, image_path in zip(plt.get_fignums(), image_path_iterator):
fig = plt.figure(fig_num)
assert image_path.endswith('.png')
# use format that does not support alpha
image_path = image_path[:-3] + 'jpg'
fig.savefig(image_path)
image_paths.append(image_path)
plt.close('all')
return figure_rst(image_paths, gallery_conf['src_dir'])
示例11: __setstate__
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def __setstate__(self, state):
version = state.pop('__mpl_version__')
restore_to_pylab = state.pop('_restore_to_pylab', False)
if version != _mpl_version:
import warnings
warnings.warn("This figure was saved with matplotlib version %s "
"and is unlikely to function correctly." %
(version, ))
self.__dict__ = state
# re-initialise some of the unstored state information
self._axobservers = []
self.canvas = None
if restore_to_pylab:
# lazy import to avoid circularity
import matplotlib.pyplot as plt
import matplotlib._pylab_helpers as pylab_helpers
allnums = plt.get_fignums()
num = max(allnums) + 1 if allnums else 1
mgr = plt._backend_mod.new_figure_manager_given_figure(num, self)
# XXX The following is a copy and paste from pyplot. Consider
# factoring to pylab_helpers
if self.get_label():
mgr.set_window_title(self.get_label())
# make this figure current on button press event
def make_active(event):
pylab_helpers.Gcf.set_active(mgr)
mgr._cidgcf = mgr.canvas.mpl_connect('button_press_event',
make_active)
pylab_helpers.Gcf.set_active(mgr)
self.number = num
plt.draw_if_interactive()
示例12: close
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def close(fignum=None):
from matplotlib.pyplot import get_fignums, close as _close
if fignum is None:
for fignum in get_fignums():
_close(fignum)
else:
_close(fignum)
示例13: newFig
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def newFig():
figs = plt.get_fignums()
for fig in range(1, DyMatplotlib.figNbr + 1):
if fig not in figs:
plt.figure(fig)
DyMatplotlib.curFigNums.append(fig)
return
fig = DyMatplotlib.curFigNums[0]
plt.close(fig)
plt.figure(fig)
del DyMatplotlib.curFigNums[0]
DyMatplotlib.curFigNums.append(fig)
示例14: plot_curve
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def plot_curve(data_list, filepath="./my_plot.png",
x_label="X", y_label="Y",
x_range=(0, 1), y_range=(0,1), color="-r", kernel_size=50, alpha=0.4, grid=True):
"""Plot a graph using matplotlib
"""
if(len(data_list) <=1):
print("[WARNING] the data list is empty, no plot will be saved.")
return
fig = plt.figure()
ax = fig.add_subplot(111, autoscale_on=False, xlim=x_range, ylim=y_range)
ax.grid(grid)
ax.set_xlabel(x_label)
ax.set_ylabel(y_label)
ax.plot(data_list, color, alpha=alpha) # The original data is showed in background
kernel = np.ones(int(kernel_size))/float(kernel_size) # Smooth the graph using a convolution
tot_data = len(data_list)
lower_boundary = int(kernel_size/2.0)
upper_boundary = int(tot_data-(kernel_size/2.0))
data_convolved_array = np.convolve(data_list, kernel, 'same')[lower_boundary:upper_boundary]
#print("arange: " + str(np.arange(tot_data)[lower_boundary:upper_boundary]))
#print("Convolved: " + str(np.arange(tot_data).shape))
ax.plot(np.arange(tot_data)[lower_boundary:upper_boundary], data_convolved_array, color, alpha=1.0) # Convolved plot
fig.savefig(filepath)
fig.clear()
plt.close(fig)
# print(plt.get_fignums()) # print the number of figures opened in background
示例15: plot_curve
# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import get_fignums [as 别名]
def plot_curve(data_list, filepath="./my_plot.png", x_label="X", y_label="Y",
x_range=(0, 1), y_range=(0,1), color="-r", kernel_size=50,
alpha=0.4, grid=True):
"""Plot a graph using matplotlib
"""
if(len(data_list) <=1): return
fig = plt.figure()
ax = fig.add_subplot(111, autoscale_on=False, xlim=x_range, ylim=y_range)
ax.grid(grid)
ax.set_xlabel(x_label)
ax.set_ylabel(y_label)
# The original data is showed in background
ax.plot(data_list, color, alpha=alpha)
# Smooth the graph using a convolution
kernel = np.ones(int(kernel_size))/float(kernel_size)
tot_data = len(data_list)
lower_boundary = int(kernel_size/2.0)
upper_boundary = int(tot_data-(kernel_size/2.0))
data_convolved_array = np.convolve(data_list, kernel, 'same')[lower_boundary:upper_boundary]
#print("arange: " + str(np.arange(tot_data)[lower_boundary:upper_boundary]))
#print("Convolved: " + str(np.arange(tot_data).shape))
ax.plot(np.arange(tot_data)[lower_boundary:upper_boundary],
data_convolved_array, color, alpha=1.0) # Convolved plot
fig.savefig(filepath)
fig.clear()
plt.close(fig)
# print(plt.get_fignums()) # print the number of figures opened in background
开发者ID:mpatacchiola,项目名称:dissecting-reinforcement-learning,代码行数:30,代码来源:temporal_differencing_control_sarsa.py