Python matplotlib.pylab.ioff() Examples
The following are 11
code examples of matplotlib.pylab.ioff().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.pylab
, or try the search function
.
Example #1
Source File: prod_basis.py From pyscf with Apache License 2.0 | 6 votes |
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)
Example #2
Source File: testfuncs.py From Computable with MIT License | 6 votes |
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()
Example #3
Source File: testfuncs.py From matplotlib-4-abaqus with MIT License | 6 votes |
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()
Example #4
Source File: testfuncs.py From neural-network-animation with MIT License | 6 votes |
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()
Example #5
Source File: testfuncs.py From ImageFusion with MIT License | 6 votes |
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()
Example #6
Source File: prod_basis.py From pyscf with Apache License 2.0 | 5 votes |
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
Example #7
Source File: speech_utils.py From python-dlpy with Apache License 2.0 | 5 votes |
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)
Example #8
Source File: testfuncs.py From Computable with MIT License | 4 votes |
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()
Example #9
Source File: testfuncs.py From matplotlib-4-abaqus with MIT License | 4 votes |
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()
Example #10
Source File: testfuncs.py From neural-network-animation with MIT License | 4 votes |
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()
Example #11
Source File: testfuncs.py From ImageFusion with MIT License | 4 votes |
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()