本文整理匯總了Python中matplotlib.pyplot.ioff方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.ioff方法的具體用法?Python pyplot.ioff怎麽用?Python pyplot.ioff使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.ioff方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: plot_convergence
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def plot_convergence(self, filename=None):
yy = self.iter_values
xx = range(len(yy))
import matplotlib.pyplot as plt
# Plot
plt.ioff()
fig = plt.figure()
fig.set_size_inches(18.5, 10.5)
font = {'size': 28}
plt.title('Value over # evaluations')
plt.xlabel('X', fontdict=font)
plt.ylabel('Y', fontdict=font)
plt.plot(xx, yy)
plt.axes().set_yscale('log')
if filename is None:
filename = 'plots/iter.png'
plt.savefig(filename, bbox_inches='tight')
plt.close(fig)
print('plotting convergence OK.. ' + filename)
示例2: generate_png_chess_dp_vertex
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def generate_png_chess_dp_vertex(self):
"""Produces pictures of the dominant product vertex a chessboard convention"""
import matplotlib.pylab as plt
plt.ioff()
dab2v = self.get_dp_vertex_doubly_sparse()
for i, ab in enumerate(dab2v):
fname = "chess-v-{:06d}.png".format(i)
print('Matrix No.#{}, Size: {}, Type: {}'.format(i+1, ab.shape, type(ab)), fname)
if type(ab) != 'numpy.ndarray': ab = ab.toarray()
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
ax.set_aspect('equal')
plt.imshow(ab, interpolation='nearest', cmap=plt.cm.ocean)
plt.colorbar()
plt.savefig(fname)
plt.close(fig)
示例3: __init__
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def __init__(self, interactive, ticks=False, figsize=None, limits=None):
"""Construct a new SimpleVectorPlotter.
interactive - boolean flag denoting interactive mode
ticks - boolean flag denoting whether to show axis tickmarks
figsize - optional figure size
limits - optional geographic limits (x_min, x_max, y_min, y_max)
"""
# if figsize:
# plt.figure(num=1, figsize=figsize)
plt.figure(num=1, figsize=figsize)
self.interactive = interactive
self.ticks = ticks
if interactive:
plt.ion()
else:
plt.ioff()
if limits is not None:
self.set_limits(*limits)
if not ticks:
self.no_ticks()
plt.axis('equal')
self._graphics = {}
self._init_colors()
示例4: render_figure_to_tensor
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def render_figure_to_tensor(figure):
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
plt.ioff()
figure.canvas.draw()
image = np.array(figure.canvas.renderer._renderer)
plt.close(figure)
del figure
image = tensor_from_rgb_image(image)
return image
示例5: __init__
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def __init__(self, fig=None, axis=None, **params):
self._create_fig = True
super(MPLPlot, self).__init__(**params)
# List of handles to matplotlib objects for animation update
self.fig_scale = self.fig_size/100.
if isinstance(self.fig_inches, (tuple, list)):
self.fig_inches = [None if i is None else i*self.fig_scale
for i in self.fig_inches]
else:
self.fig_inches *= self.fig_scale
if self.fig_latex:
self.fig_rcparams['text.usetex'] = True
if self.renderer.interactive:
plt.ion()
self._close_figures = False
elif not self.renderer.notebook_context:
plt.ioff()
fig, axis = self._init_axis(fig, axis)
self.handles['fig'] = fig
self.handles['axis'] = axis
self.handles['bbox_extra_artists'] = []
示例6: update_plot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def update_plot(self):
plt.ioff()
col = self.picker.currentText()
plt.figure()
arr = self.df[col].dropna()
if self.df[col].dtype.name in ['object', 'bool', 'category']:
ax = sns.countplot(y=arr, color='grey', order=arr.value_counts().iloc[:10].index)
else:
ax = sns.distplot(arr, color='black', hist_kws=dict(color='grey', alpha=1))
self.figure_viewer.setFigure(ax.figure)
# Examples
示例7: _plot_image
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def _plot_image(self, axis: plt.Axes=None, title: str=''):
plt.ioff()
if axis is None:
fig, axis = plt.subplots()
axis.imshow(self.image.array, cmap=get_dicom_cmap())
# show vertical/axial profiles
left_profile = self.positions['vertical left']
right_profile = self.positions['vertical right']
axis.axvline(left_profile, color='b')
axis.axvline(right_profile, color='b')
# show horizontal/transverse profiles
bottom_profile = self.positions['horizontal bottom']
top_profile = self.positions['horizontal top']
axis.axhline(bottom_profile, color='b')
axis.axhline(top_profile, color='b')
_remove_ticklabels(axis)
axis.set_title(title)
示例8: _plot_symmetry
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def _plot_symmetry(self, direction: str, axis: plt.Axes=None):
plt.ioff()
if axis is None:
fig, axis = plt.subplots()
data = self.symmetry[direction.lower()]
axis.set_title(direction.capitalize() + " Symmetry")
axis.plot(data['profile'].values)
# plot lines
cax_idx = data['profile'].fwxm_center()
axis.axvline(data['profile left'], color='g', linestyle='-.')
axis.axvline(data['profile right'], color='g', linestyle='-.')
axis.axvline(cax_idx, color='m', linestyle='-.')
# plot symmetry array
if not data['array'] == 0:
twin_axis = axis.twinx()
twin_axis.plot(range(cax_idx, data['profile right']), data['array'][int(round(len(data['array'])/2)):])
twin_axis.set_ylabel("Symmetry (%)")
_remove_ticklabels(axis)
# plot profile mirror
central_idx = int(round(data['profile'].values.size / 2))
offset = cax_idx - central_idx
mirror_vals = data['profile'].values[::-1]
axis.plot(data['profile']._indices + 2 * offset, mirror_vals)
示例9: render_figure_to_tensor
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def render_figure_to_tensor(figure):
"""@TODO: Docs. Contribution is welcome."""
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
plt.ioff()
figure.canvas.draw()
image = np.array(figure.canvas.renderer._renderer) # noqa: WPS437
plt.close(figure)
del figure
image = tensor_from_rgb_image(image)
return image
示例10: plotBy
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def plotBy(self,by,variable,df, gridLines = False):
if not isinstance(df,PowerCurve):
kind = 'scatter'
else:
kind = 'line'
df=df.data_frame[df.data_frame[self.analysis.baseline.wind_speed_column] <= self.analysis.allMeasuredPowerCurve.cut_out_wind_speed]
try:
from matplotlib import pyplot as plt
plt.ioff()
ax = df.plot(kind=kind,x=by ,y=variable,title=variable+" By " +by,alpha=0.6,legend=None)
ax.set_xlim([df[by].min()-1,df[by].max()+1])
ax.set_xlabel(by)
ax.set_ylabel(variable)
if gridLines:
ax.grid(True)
file_out = self.path + "/"+variable.replace(" ","_")+"_By_"+by.replace(" ","_")+".png"
chckMake(self.path)
plt.savefig(file_out)
plt.close()
return file_out
except:
Status.add("Tried to make a " + variable.replace(" ","_") + "_By_"+by.replace(" ","_")+" chart. Couldn't.", verbosity=2)
示例11: plot_multiple
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def plot_multiple(self, windSpeedCol, powerCol, meanPowerCurveObj):
#plt.ioff()
plotTitle = "Power Curve"
meanPowerCurve = meanPowerCurveObj.data_frame[[windSpeedCol,powerCol,'Data Count']][meanPowerCurveObj.data_frame['Data Count'] > 0 ].reset_index().set_index(windSpeedCol)
ax = meanPowerCurve[powerCol].plot(color='#00FF00',alpha=0.95,linestyle='--',label='Mean Power Curve')
colourmap = plt.cm.gist_ncar
colours = [colourmap(i) for i in np.linspace(0, 0.9, len(self.analysis.dataFrame[self.analysis.nameColumn].unique()))]
for i,name in enumerate(self.analysis.dataFrame[self.analysis.nameColumn].unique()):
ax = self.analysis.dataFrame[self.analysis.dataFrame[self.analysis.nameColumn] == name].plot(ax = ax, kind='scatter', x=windSpeedCol, y=powerCol, title=plotTitle, alpha=0.2, label=name, color = colours[i])
ax.legend(loc=4, scatterpoints = 1)
ax.set_xlim([min(self.analysis.dataFrame[windSpeedCol].min(),meanPowerCurve.index.min()), max(self.analysis.dataFrame[windSpeedCol].max(),meanPowerCurve.index.max()+2.0)])
ax.set_xlabel(windSpeedCol + ' (m/s)')
ax.set_ylabel(powerCol + ' (kW)')
示例12: grid_visual
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def grid_visual(data):
"""
This function displays a grid of images to show full misclassification
:param data: grid data of the form;
[nb_classes : nb_classes : img_rows : img_cols : nb_channels]
:return: if necessary, the matplot figure to reuse
"""
import matplotlib.pyplot as plt
# Ensure interactive mode is disabled and initialize our graph
plt.ioff()
figure = plt.figure()
figure.canvas.set_window_title('Cleverhans: Grid Visualization')
# Add the images to the plot
num_cols = data.shape[0]
num_rows = data.shape[1]
num_channels = data.shape[4]
current_row = 0
for y in xrange(num_rows):
for x in xrange(num_cols):
figure.add_subplot(num_rows, num_cols, (x + 1) + (y * num_cols))
plt.axis('off')
if num_channels == 1:
plt.imshow(data[x, y, :, :, 0], cmap='gray')
else:
plt.imshow(data[x, y, :, :, :])
# Draw the plot and return
plt.show()
return figure
示例13: generate_png_spy_dp_vertex
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def generate_png_spy_dp_vertex(self):
"""Produces pictures of the dominant product vertex in a common black-and-white way"""
import matplotlib.pyplot as plt
plt.ioff()
dab2v = self.get_dp_vertex_doubly_sparse()
for i,ab2v in enumerate(dab2v):
plt.spy(ab2v.toarray())
fname = "spy-v-{:06d}.png".format(i)
print(fname)
plt.savefig(fname, bbox_inches='tight')
plt.close()
return 0
示例14: test_scatterplot_w_ioff
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def test_scatterplot_w_ioff(self):
"""Check if scatterplot generates"""
plt.ioff()
figs = plot.scatterplot(self.testInst, 'longitude', 'latitude',
'slt', [0.0, 24.0])
axes = figs[0].get_axes()
assert len(figs) == 1
assert len(axes) == 3
assert not mpl.is_interactive()
示例15: __call__
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import ioff [as 別名]
def __call__(self, **kwargs):
"""Figure realizer
The Figure class only keeps track of a root panel. It does
not contain an actual matplotlib Figure instance. Whenever a
figure needs to be created, Figure creates a new matplotlib
Figure in order to drew/rendered/realized the figure.
Args:
**kwargs (dict): Arbitrary Figure-specific keyworded
arguments that are used to construct the matplotlib
Figure.
"""
kwprops = merge_dict(self.kwprops, kwargs)
style = kwprops.pop('style')
with mpl.rc_context():
mpl.rcdefaults()
plt.style.use(style)
imode = mpl.is_interactive()
if imode:
plt.ioff()
fig = plt.figure(**kwprops)
ax = newaxes(fig)
yield fig, ax
if imode:
plt.ion()