本文整理汇总了Python中matplotlib.pylab.ioff方法的典型用法代码示例。如果您正苦于以下问题:Python pylab.ioff方法的具体用法?Python pylab.ioff怎么用?Python pylab.ioff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.pylab
的用法示例。
在下文中一共展示了pylab.ioff方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_png_chess_dp_vertex
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab 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)
示例2: plotallfuncs
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ioff [as 别名]
def plotallfuncs(allfuncs=allfuncs):
from matplotlib import pylab as pl
pl.ioff()
nnt = NNTester(npoints=1000)
lpt = LinearTester(npoints=1000)
for func in allfuncs:
print(func.title)
nnt.plot(func, interp=False, plotter='imshow')
pl.savefig('%s-ref-img.png' % func.func_name)
nnt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-nn-img.png' % func.func_name)
lpt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-lin-img.png' % func.func_name)
nnt.plot(func, interp=False, plotter='contour')
pl.savefig('%s-ref-con.png' % func.func_name)
nnt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-nn-con.png' % func.func_name)
lpt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-lin-con.png' % func.func_name)
pl.ion()
示例3: plotallfuncs
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ioff [as 别名]
def plotallfuncs(allfuncs=allfuncs):
from matplotlib import pylab as pl
pl.ioff()
nnt = NNTester(npoints=1000)
lpt = LinearTester(npoints=1000)
for func in allfuncs:
print(func.title)
nnt.plot(func, interp=False, plotter='imshow')
pl.savefig('%s-ref-img.png' % func.__name__)
nnt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-nn-img.png' % func.__name__)
lpt.plot(func, interp=True, plotter='imshow')
pl.savefig('%s-lin-img.png' % func.__name__)
nnt.plot(func, interp=False, plotter='contour')
pl.savefig('%s-ref-con.png' % func.__name__)
nnt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-nn-con.png' % func.__name__)
lpt.plot(func, interp=True, plotter='contour')
pl.savefig('%s-lin-con.png' % func.__name__)
pl.ion()
示例4: generate_png_spy_dp_vertex
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab 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
示例5: convert_one_audio_file_to_specgram
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ioff [as 别名]
def convert_one_audio_file_to_specgram(local_audio_file, converted_local_png_file):
'''
Convert a local audio file into a png format with spectrogram.
Parameters
----------
local_audio_file : string
Local location to the audio file to be converted.
converted_local_png_file : string
Local location to store the converted audio file
Returns
-------
None
Raises
------
DLPyError
If anything goes wrong, it complains and prints the appropriate message.
'''
try:
import soundfile as sf
import matplotlib.pylab as plt
except (ModuleNotFoundError, ImportError):
raise DLPyError('cannot import soundfile')
data, sampling_rate = sf.read(local_audio_file)
fig, ax = plt.subplots(1)
fig.subplots_adjust(left=0, right=1, bottom=0, top=1)
ax.axis('off')
ax.specgram(x=data, Fs=sampling_rate)
ax.axis('off')
fig.savefig(converted_local_png_file, dpi=300, frameon='false')
# this is the key to avoid mem leaking in notebook
plt.ioff()
plt.close(fig)
示例6: plot
# 需要导入模块: from matplotlib import pylab [as 别名]
# 或者: from matplotlib.pylab import ioff [as 别名]
def plot(self, func, interp=True, plotter='imshow'):
import matplotlib as mpl
from matplotlib import pylab as pl
if interp:
lpi = self.interpolator(func)
z = lpi[self.yrange[0]:self.yrange[1]:complex(0, self.nrange),
self.xrange[0]:self.xrange[1]:complex(0, self.nrange)]
else:
y, x = np.mgrid[
self.yrange[0]:self.yrange[1]:complex(0, self.nrange),
self.xrange[0]:self.xrange[1]:complex(0, self.nrange)]
z = func(x, y)
z = np.where(np.isinf(z), 0.0, z)
extent = (self.xrange[0], self.xrange[1],
self.yrange[0], self.yrange[1])
pl.ioff()
pl.clf()
pl.hot() # Some like it hot
if plotter == 'imshow':
pl.imshow(np.nan_to_num(z), interpolation='nearest', extent=extent,
origin='lower')
elif plotter == 'contour':
Y, X = np.ogrid[
self.yrange[0]:self.yrange[1]:complex(0, self.nrange),
self.xrange[0]:self.xrange[1]:complex(0, self.nrange)]
pl.contour(np.ravel(X), np.ravel(Y), z, 20)
x = self.x
y = self.y
lc = mpl.collections.LineCollection(
np.array([((x[i], y[i]), (x[j], y[j]))
for i, j in self.tri.edge_db]),
colors=[(0, 0, 0, 0.2)])
ax = pl.gca()
ax.add_collection(lc)
if interp:
title = '%s Interpolant' % self.name
else:
title = 'Reference'
if hasattr(func, 'title'):
pl.title('%s: %s' % (func.title, title))
else:
pl.title(title)
pl.show()
pl.ion()