Python matplotlib.pyplot.ioff() Examples
The following are 30
code examples of matplotlib.pyplot.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.pyplot
, 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: visualization.py From pytorch-tools with MIT License | 6 votes |
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
Example #3
Source File: power_curve.py From PCWG with MIT License | 6 votes |
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)')
Example #4
Source File: dataframe_explorer.py From pandasgui with MIT License | 6 votes |
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
Example #5
Source File: plots.py From PCWG with MIT License | 6 votes |
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)
Example #6
Source File: solver.py From osim-rl with MIT License | 6 votes |
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)
Example #7
Source File: simplevectorplotter.py From osgeopy-code with MIT License | 6 votes |
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()
Example #8
Source File: visualization.py From catalyst with Apache License 2.0 | 6 votes |
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
Example #9
Source File: plot.py From holoviews with BSD 3-Clause "New" or "Revised" License | 6 votes |
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'] = []
Example #10
Source File: flatsym.py From pylinac with MIT License | 6 votes |
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)
Example #11
Source File: flatsym.py From pylinac with MIT License | 6 votes |
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)
Example #12
Source File: plots.py From PCWG with MIT License | 5 votes |
def plotPowerCurveSensitivityVariationMetrics(self): try: from matplotlib import pyplot as plt plt.ioff() (self.analysis.powerCurveSensitivityVariationMetrics.dropna()*100.).plot(kind = 'bar', title = 'Summary of Power Curve Variation by Variable. Significance Threshold = %.2f%%' % (self.analysis.sensitivityAnalysisThreshold * 100), figsize = (12,8), fontsize = 6) plt.ylabel('Variation Metric (%)') file_out = self.path + os.sep + 'Power Curve Sensitivity Analysis Variation Metric Summary.png' plt.tight_layout() plt.savefig(file_out) plt.close('all') except: Status.add("Tried to plot summary of Power Curve Sensitivity Analysis Variation Metric. Couldn't.", verbosity=2) self.analysis.powerCurveSensitivityVariationMetrics.to_csv(self.path + os.sep + 'Power Curve Sensitivity Analysis Variation Metric.csv')
Example #13
Source File: 000_visualization.py From Tensorflow-Computer-Vision-Tutorial with MIT License | 5 votes |
def show_conv(): filter = np.array([ [1, 1, 1], [0, 0, 0], [-1, -1, -1]]) plt.figure(0, figsize=(9, 5)) ax1 = plt.subplot(121) ax1.imshow(image, cmap='gray') plt.xticks(()) plt.yticks(()) ax2 = plt.subplot(122) plt.ion() texts = [] feature_map = np.zeros((26, 26)) flip_filter = np.flipud(np.fliplr(filter)) # flip both sides of the filter for i in range(26): for j in range(26): if texts: fm.remove() for n in range(3): for m in range(3): if len(texts) != 9: texts.append(ax1.text(j+m, i+n, filter[n, m], color='w', size=8, ha='center', va='center',)) else: texts[n*3+m].set_position((j+m, i+n)) feature_map[i, j] = np.sum(flip_filter * image[i:i+3, j:j+3]) fm = ax2.imshow(feature_map, cmap='gray', vmax=255*3, vmin=-255*3) plt.xticks(()) plt.yticks(()) plt.pause(0.001) plt.ioff() plt.show()
Example #14
Source File: im_utils.py From deep-transfer with Apache License 2.0 | 5 votes |
def tensor_imshow(tensor, title=None): inp = tensor.numpy().transpose((1, 2, 0)) inp = np.clip(inp, 0, 1) plt.imshow(inp) if title is not None: plt.title(title) if plt.isinteractive(): plt.ioff() plt.show() # import torch # tensor_imshow(torch.randn(3, 256, 512), 'pytorch tensor')
Example #15
Source File: block.py From bifrost with BSD 3-Clause "New" or "Revised" License | 5 votes |
def save_waterfall_plot(self, waterfall_matrix): """Save an image of the waterfall plot using thread-safe backend for pyplot, and labelling the plot using the header information from the ring @param[in] waterfall_matrix x axis is frequency and y axis is time. Values should be power. """ import matplotlib # Use a graphical backend which supports threading matplotlib.use('Agg') from matplotlib import pyplot as plt plt.ioff() print "Interactive mode off" print waterfall_matrix.shape fig = pylab.figure() ax = fig.gca() header = self.header ax.set_xticks( np.arange(0, 1.33, 0.33) * waterfall_matrix.shape[1]) ax.set_xticklabels( header['fch1'] - np.arange(0, 4) * header['foff']) ax.set_xlabel("Frequency [MHz]") ax.set_yticks( np.arange(0, 1.125, 0.125) * waterfall_matrix.shape[0]) ax.set_yticklabels( header['tstart'] + header['tsamp'] * np.arange(0, 1.125, 0.125) * waterfall_matrix.shape[0]) ax.set_ylabel("Time (s)") plt.pcolormesh( waterfall_matrix, axes=ax, figure=fig) fig.autofmt_xdate() fig.savefig( self.imagename, bbox_inches='tight') plt.close(fig)
Example #16
Source File: plots.py From PCWG with MIT License | 5 votes |
def plotTurbCorrectedPowerCurve(self, windSpeedCol, powerCol, meanPowerCurveObj): try: from matplotlib import pyplot as plt plt.ioff() if (windSpeedCol == self.analysis.densityCorrectedHubWindSpeed) or ((windSpeedCol == self.analysis.baseline.wind_speed_column) and (self.analysis.densityCorrectionActive)): plotTitle = "Power Curve (corrected to {dens} kg/m^3)".format(dens=self.analysis.referenceDensity) else: plotTitle = "Power Curve" ax = self.analysis.dataFrame.plot(kind='scatter', x=windSpeedCol, y=powerCol, title=plotTitle, alpha=0.15, label='Filtered Data') if self.analysis.specified_power_curve is not None: has_spec_pc = len(self.analysis.specified_power_curve.power_curve_levels.index) != 0 else: has_spec_pc = False if has_spec_pc: ax = self.analysis.specified_power_curve.power_curve_levels.sort_index()['Specified Power'].plot(ax = ax, color='#FF0000',alpha=0.9,label='Specified') meanPowerCurve = meanPowerCurveObj.power_curve_levels[[windSpeedCol,powerCol,'Data Count']][self.analysis.allMeasuredPowerCurve.power_curve_levels['Data Count'] > 0 ].reset_index().set_index(windSpeedCol) ax = meanPowerCurve[powerCol].plot(ax = ax,color='#00FF00',alpha=0.95,linestyle='--', label='Mean Power Curve') ax2 = ax.twinx() if has_spec_pc: ax.set_xlim([self.analysis.specified_power_curve.power_curve_levels.index.min(), self.analysis.specified_power_curve.power_curve_levels.index.max()+2.0]) ax2.set_xlim([self.analysis.specified_power_curve.power_curve_levels.index.min(), self.analysis.specified_power_curve.power_curve_levels.index.max()+2.0]) else: ax.set_xlim([min(self.analysis.dataFrame[windSpeedCol].min(),meanPowerCurve.index.min()), max(self.analysis.dataFrame[windSpeedCol].max(),meanPowerCurve.index.max()+2.0)]) ax2.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(self.analysis.baseline.wind_speed_column + ' (m/s)') ax.set_ylabel(powerCol + ' (kW)') refTurbCol = 'Specified Turbulence' if self.analysis.powerCurveMode == 'Specified' else self.analysis.hubTurbulence ax2.plot(self.analysis.powerCurve.power_curve_levels.sort_index().index, self.analysis.powerCurve.power_curve_levels.sort_index()[refTurbCol] * 100., 'm--', label = 'Reference TI') ax2.set_ylabel('Reference TI (%)') h1, l1 = ax.get_legend_handles_labels() h2, l2 = ax2.get_legend_handles_labels() ax.legend(h1+h2, l1+l2, loc=4, scatterpoints = 1) file_out = self.path + "/PowerCurve TI Corrected - " + powerCol + " vs " + windSpeedCol + ".png" chckMake(self.path) plt.savefig(file_out) plt.close() return file_out except: Status.add("Tried to make a TI corrected power curve scatter chart for %s. Couldn't." % meanPowerCurveObj.name, verbosity=2)
Example #17
Source File: plots.py From PCWG with MIT License | 5 votes |
def plotPowerCurveSensitivity(self, sensCol): try: df = self.analysis.powerCurveSensitivityResults[sensCol].reset_index() from matplotlib import pyplot as plt plt.ioff() fig = plt.figure(figsize = (12,5)) fig.suptitle('Power Curve Sensitivity to %s' % sensCol) ax1 = fig.add_subplot(121) ax1.hold(True) ax2 = fig.add_subplot(122) ax2.hold(True) power_column = self.analysis.measuredTurbulencePower if self.analysis.turbRenormActive else self.analysis.actualPower for label in self.analysis.sensitivityLabels.keys(): filt = df['Bin'] == label ax1.plot(df['Wind Speed Bin'][filt], df[power_column][filt], label = label, color = self.analysis.sensitivityLabels[label]) ax2.plot(df['Wind Speed Bin'][filt], df['Energy Delta MWh'][filt], label = label, color = self.analysis.sensitivityLabels[label]) ax1.set_xlabel('Wind Speed (m/s)') ax1.set_ylabel('Power (kW)') ax2.set_xlabel('Wind Speed (m/s)') ax2.set_ylabel('Energy Difference from Mean (MWh)') box1 = ax1.get_position() box2 = ax2.get_position() ax1.set_position([box1.x0 - 0.05 * box1.width, box1.y0 + box1.height * 0.17, box1.width * 0.95, box1.height * 0.8]) ax2.set_position([box2.x0 + 0.05 * box2.width, box2.y0 + box2.height * 0.17, box2.width * 1.05, box2.height * 0.8]) handles, labels = ax1.get_legend_handles_labels() fig.legend(handles, labels, loc='lower center', ncol = len(self.analysis.sensitivityLabels.keys()), fancybox = True, shadow = True) file_out = self.path + os.sep + 'Power Curve Sensitivity to %s.png' % sensCol chckMake(self.path) fig.savefig(file_out) plt.close() except: Status.add("Tried to make a plot of power curve sensitivity to %s. Couldn't." % sensCol, verbosity=2)
Example #18
Source File: plot_utils.py From teachDeepRL with MIT License | 5 votes |
def random_plot_gif(bk, step=250, gifname='test', gifdir='graphics/', ax=None, xlim=[0,1], ylim=[0,1], fig_size=(9,6), save_imgs=False, title=True, bar=True): gifdir = 'graphics/' + gifdir plt.ioff() # Create target Directory if don't exist tmpdir = 'tmp/' tmppath = gifdir + 'tmp/' if not os.path.exists(gifdir): os.mkdir(gifdir) print("Directory ", gifdir, " Created ") if not os.path.exists(tmppath): os.mkdir(tmppath) print("Directory ", tmppath, " Created ") print("Making " + tmppath + gifname + ".gif") images = [] tasks = np.array(bk['tasks']) for i,(c_grids, c_xs, c_ys) in enumerate(zip(bk['comp_grids'], bk['comp_xs'], bk['comp_ys'])): plt.figure(figsize=fig_size) ax = plt.gca() draw_competence_grid(ax, c_grids, c_xs, c_ys) ax.scatter(tasks[i*step:(i+1)*step, 0], tasks[i*step:(i+1)*step, 1], c='blue', s=2, zorder=2) ax.set_xlim(left=xlim[0], right=xlim[1]) ax.set_ylim(bottom=ylim[0], top=ylim[1]) ax.tick_params(axis='both', which='major', labelsize=20) ax.set_aspect('equal', 'box') f_name = gifdir+tmpdir+gifname+"_{}.png".format(i) if title: plt.suptitle('Episode {}'.format(i*step), fontsize=20) if save_imgs: plt.savefig(f_name, bbox_inches='tight') images.append(plt_2_rgb(ax)) plt.close() imageio.mimsave(gifdir + gifname + '.gif', images, duration=0.4)
Example #19
Source File: plots.py From PCWG with MIT License | 5 votes |
def plot_multiple(self, windSpeedCol, powerCol, meanPowerCurveObj): try: from matplotlib import pyplot as plt 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)') file_out = self.path + "/Multiple Dataset PowerCurve - " + powerCol + " vs " + windSpeedCol + ".png" chckMake(self.path) plt.savefig(file_out) plt.close() return file_out except: Status.add("Tried to make a power curve scatter chart for multiple data source (%s). Couldn't." % meanPowerCurveObj.name, verbosity=2)
Example #20
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 #21
Source File: post.py From section-properties with MIT License | 5 votes |
def setup_plot(ax, pause): """Executes code required to set up a matplotlib figure. :param ax: Axes object on which to plot :type ax: :class:`matplotlib.axes.Axes` :param bool pause: If set to true, the figure pauses the script until the window is closed. If set to false, the script continues immediately after the window is rendered. """ if not pause: plt.ion() plt.show() else: plt.ioff()
Example #22
Source File: plot_utils.py From teachDeepRL with MIT License | 5 votes |
def region_plot_gif(all_boxes, interests, iterations, goals, gifname='riac', rewards=None, ep_len=None, gifdir='graphics/', xlim=[0,1], ylim=[0,1], scatter=False, fs=(9,6), plot_step=250): gifdir = 'graphics/' + gifdir ft_off = 15 plt.ioff() print("Making an exploration GIF: " + gifname) # Create target Directory if don't exist tmpdir = 'tmp/' tmppath = gifdir + 'tmp/' if not os.path.exists(gifdir): os.mkdir(gifdir) print("Directory ", gifdir, " Created ") if not os.path.exists(tmppath): os.mkdir(tmppath) print("Directory ", tmppath, " Created ") filenames = [] images = [] steps = [] mean_rewards = [] for i in range(len(goals)): if i > 0 and (i % plot_step == 0): f, (ax0) = plt.subplots(1, 1, figsize=fs) ax = [ax0] if scatter: scatter_plot(goals[0:i], ax=ax[0], emph_data=goals[i - plot_step:i], xlim=xlim, ylim=ylim) idx = 0 cur_idx = 0 for j in range(len(all_boxes)): if iterations[j] > i: break else: cur_idx = j plot_regions(all_boxes[cur_idx], interests[cur_idx], ax=ax[0], xlim=xlim, ylim=ylim) f_name = gifdir+tmpdir+"scatter_{}.png".format(i) plt.suptitle('Episode {}'.format(i), fontsize=ft_off+0) images.append(plt_2_rgb(plt.gca())) plt.close(f) imageio.mimsave(gifdir + gifname + '.gif', images, duration=0.4)
Example #23
Source File: plotting_utils.py From differentiable-particle-filters with MIT License | 5 votes |
def view_data(data): # overview plot for poses in data['s']: plt.figure('Overview') plt.plot(poses[:, 0], poses[:, 1]) # # sample plot # for poses, velocities, rgbds in zip(data['pose'], data['vel'], data['rgbd']): # # for poses in data['pose']: # plt.ioff() # plt.figure('Sample') # # plt.plot(poses[:, 0], 'r-') # # plt.plot(poses[:, 1], 'g-') # plt.plot(poses[:, 2], 'b-') # # plt.plot(velocities[:, 0], 'r--') # # plt.plot(velocities[:, 1], 'g--') # plt.plot(velocities[:, 2], 'b--') # plt.show() # # # for i in range(100): # # plt.figure('Normalized image') # # plt.gca().clear() # # plt.imshow(0.5 + rgbds[i, :, :, :3]/10, interpolation='nearest') # # plt.pause(0.001) # # # # plt.figure('Depth image') # # plt.gca().clear() # # plt.imshow(0.5 + rgbds[i, :, :, 3] / 10, interpolation='nearest', cmap='coolwarm', vmin=0.0, vmax=1.0) # # plt.pause(0.001) # # # # plt.figure('Real image') # # plt.gca().clear() # # plt.imshow((rgbds*stds['rgbd'][0] + means['rgbd'][0])[i, :, :, :3]/255.0, interpolation='nearest') # # plt.pause(0.1)
Example #24
Source File: plotting_utils.py From differentiable-particle-filters with MIT License | 5 votes |
def show_pause(show=False, pause=0.0): '''Shows a plot by either blocking permanently using show or temporarily using pause.''' if show: plt.ioff() plt.show() elif pause: plt.ion() plt.pause(pause)
Example #25
Source File: visualize.py From acc with MIT License | 5 votes |
def show_final_plots(self): """ show the final plots """ # plt.ioff() plt.show() # input("Press [enter] to close the plots.") plt.close()
Example #26
Source File: evaluator.py From tfnn with MIT License | 5 votes |
def hold_plot(): print('Press any key to exit...') plt.ioff() plt.waitforbuttonpress() plt.close()
Example #27
Source File: report.py From keyphrase-generation-rl with MIT License | 5 votes |
def plot_train_valid_curve(train_loss, valid_loss, plot_every, path, loss_label): #plt.ioff() title = "Training and validation %s for every %d iterations" % (loss_label.lower(), plot_every) plt.figure() plt.title(title) plt.xlabel("Checkpoints") plt.ylabel(loss_label) num_checkpoints = len(train_loss) X = list(range(num_checkpoints)) plt.plot(X, train_loss, label="training") plt.plot(X, valid_loss, label="validation") plt.legend() plt.savefig("%s_%s.pdf" % (path, loss_label.lower()))
Example #28
Source File: general.py From marvin with BSD 3-Clause "New" or "Revised" License | 5 votes |
def turn_off_ion(show_plot=True): ''' Turns off the Matplotlib plt interactive mode Context manager to temporarily disable the interactive Matplotlib plotting functionality. Useful for only returning Figure and Axes objects Parameters: show_plot (bool): If True, turns off the plotting Example: >>> >>> with turn_off_ion(show_plot=False): >>> do_some_stuff >>> ''' plt_was_interactive = plt.isinteractive() if not show_plot and plt_was_interactive: plt.ioff() fignum_init = plt.get_fignums() yield plt if show_plot: plt.ioff() plt.show() else: for ii in plt.get_fignums(): if ii not in fignum_init: plt.close(ii) # Restores original ion() status if plt_was_interactive and not plt.isinteractive(): plt.ion()
Example #29
Source File: b_sbn_arm.py From ARM-gradient with MIT License | 5 votes |
def fig_gnrt(figs,epoch,show=False,bny=True,name_fig=None): ''' input:N*28*28 ''' sns.set_style("whitegrid", {'axes.grid' : False}) plt.ioff() if bny: b = figs > 0.5 figs = b.astype('float') nx = ny = 10 canvas = np.empty((28*ny, 28*nx)) for i in range(nx): for j in range(ny): canvas[(nx-i-1)*28:(nx-i)*28, j*28:(j+1)*28] = figs[i*nx+j] plt.figure(figsize=(8, 10)) plt.imshow(canvas, origin="upper", cmap="gray") plt.tight_layout() if name_fig == None: path = os.getcwd()+'/out/' if not os.path.exists(path): os.makedirs(path) name_fig = path + str(epoch)+'.png' plt.savefig(name_fig, bbox_inches='tight') plt.close('all') if show: plt.show() #%%
Example #30
Source File: callbacks.py From costar_plan with Apache License 2.0 | 5 votes |
def on_epoch_end(self, epoch, logs={}): # take the model and print it out if self.use_noise: z= np.random.random((self.targets[0].shape[0], self.num_hypotheses, self.noise_dim)) arms, grippers, label, probs, v = self.predictor.predict( self.features[:4] + [z]) else: arms, grippers, label, probs, v = self.predictor.predict( self.features[:4]) plt.ioff() if self.verbose: print("============================") for j in range(self.num): name = os.path.join(self.directory, "predictor_epoch%03d_result%d.png"%(epoch+1,j)) if self.verbose: print("----------------") print(name) print("max(p(o' | x)) =", np.argmax(probs[j])) print("v(x) =", v[j]) for i in range(self.num_hypotheses): if self.verbose: print("Arms = ", arms[j][i]) print("Gripper = ", grippers[j][i]) print("Label = ", np.argmax(label[j][i])) if self.verbose: print("Arm/gripper target = ", self.targets[0][j,:7]) print("Label target = ", np.argmax(self.targets[0][j,7:]))