def _plot_default(self): # Create data x = linspace(-5, 15.0, 100) y = jn(3, x) pd = ArrayPlotData(index=x, value=y) zoomable_plot = Plot(pd) zoomable_plot.plot(('index', 'value'), name='external', color='red', line_width=3) # Attach tools to the plot zoom = ZoomTool(component=zoomable_plot, tool_mode="box", always_on=False) zoomable_plot.overlays.append(zoom) zoomable_plot.tools.append(PanTool(zoomable_plot)) # Create a second inset plot, not resizable, not zoom-able inset_plot = Plot(pd) inset_plot.plot(('index', 'value'), color='blue') inset_plot.resizable = '' inset_plot.bounds = [250, 150] inset_plot.position = [450, 350] inset_plot.border_visible = True # Create a container and add our plots container = OverlayPlotContainer() container.add(zoomable_plot) container.add(inset_plot) return container
def _signals_plot_default(self): print('_signals_plot_default') """Create the Plot instance.""" plot = Plot() plot.add(self.signals_renderer) x_axis = PlotAxis(component=plot, mapper=self.signals_renderer.index_mapper, orientation='bottom') # y_axis = PlotAxis(component=plot, # mapper=self.signals_renderer.value_mapper, # orientation='left') plot.overlays.extend([x_axis]) plot.origin_axis_visible = False plot.padding_top = 0 plot.padding_left = 0 plot.padding_right = 0 plot.padding_bottom = 50 plot.border_visible = False plot.bgcolor = "white" plot.use_downsampling = True return plot
def _create_plot_component(): # Create some x-y data series to plot x = linspace(-2.0, 10.0, 100) pd = ArrayPlotData(index=x) for i in range(5): pd.set_data("y" + str(i), jn(i, x)) # Create some line plots of some of the data plot1 = Plot(pd) plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red") plot1.plot(("index", "y3"), name="j_3", color="blue") # Tweak some of the plot properties plot1.title = "Inset Plot" plot1.padding = 50 # Attach some tools to the plot plot1.tools.append(PanTool(plot1)) zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False) plot1.overlays.append(zoom) # Create a second scatter plot of one of the datasets, linking its # range to the first plot plot2 = Plot(pd, range2d=plot1.range2d, padding=50) plot2.plot(('index', 'y3'), type="scatter", color="blue", marker="circle") plot2.resizable = "" plot2.bounds = [250, 250] plot2.position = [550, 150] plot2.bgcolor = "white" plot2.border_visible = True plot2.unified_draw = True plot2.tools.append(PanTool(plot2)) plot2.tools.append(MoveTool(plot2, drag_button="right")) zoom = ZoomTool(component=plot2, tool_mode="box", always_on=False) plot2.overlays.append(zoom) # Create a container and add our plots container = OverlayPlotContainer() container.add(plot1) container.add(plot2) return container
def _plot_default(self): distr_len = len(self.data) # PolygonPlot holding the circles of the Hinton diagram polyplot = Plot(self.plot_data) for idx in range(distr_len): p = polyplot.plot(('x%d' % idx, 'y%d' % idx), type="polygon", face_color=get_class_color(idx), edge_color='black') self._set_title(polyplot) self._remove_grid_and_axes(polyplot) # create x axis for labels axis = self._create_increment_one_axis(polyplot, 1., distr_len, 'bottom') self._add_index_axis(polyplot, axis) # create y axis for probability density #prob_axis = self._create_probability_axis(polyplot) #polyplot.value_axis = prob_axis #polyplot.underlays.append(prob_axis) # tweak some of the plot properties range2d = DataRange2D(low=(0.5, 0.), high=(distr_len + 0.5, 1.)) polyplot.range2d = range2d polyplot.aspect_ratio = ((range2d.x_range.high - range2d.x_range.low) / (range2d.y_range.high - range2d.y_range.low)) polyplot.border_visible = False polyplot.padding = [0, 0, 25, 25] # create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer=True, valign='center') container.add(polyplot) container.bgcolor = 0xFFFFFF # light gray: 0xEEEEEE self.decorate_plot(container, self.data) return container
def _plot_default(self): distr_len = len(self.data) # PolygonPlot holding the circles of the Hinton diagram polyplot = Plot(self.plot_data) for idx in range(distr_len): p = polyplot.plot(('x%d' % idx, 'y%d' % idx), type="polygon", face_color=get_class_color(idx), edge_color='black') self._set_title(polyplot) self._remove_grid_and_axes(polyplot) # create x axis for labels axis = self._create_increment_one_axis(polyplot, 1., distr_len, 'bottom') self._add_index_axis(polyplot, axis) # create y axis for probability density #prob_axis = self._create_probability_axis(polyplot) #polyplot.value_axis = prob_axis #polyplot.underlays.append(prob_axis) # tweak some of the plot properties range2d = DataRange2D(low=(0.5, 0.), high=(distr_len+0.5, 1.)) polyplot.range2d = range2d polyplot.aspect_ratio = ((range2d.x_range.high - range2d.x_range.low) / (range2d.y_range.high - range2d.y_range.low)) polyplot.border_visible = False polyplot.padding = [0, 0, 25, 25] # create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer=True, valign='center') container.add(polyplot) container.bgcolor = 0xFFFFFF # light gray: 0xEEEEEE self.decorate_plot(container, self.data) return container
def _create_1D1_plot(self): index = 0 plot0 = Plot(self.plotdata, padding=0) plot0.padding_left = 5 plot0.padding_bottom = 5 Container = OverlayPlotContainer(padding = 50, fill_padding = True, bgcolor = "lightgray", use_backbuffer=True) y1 = range(len(self.PCAData.batchs[0].prescores)) points = [] for batch in self.PCAData.batchs: if (self.active_scores_combobox == "Post Scores"): x1 = self.PCAData.batchs[index].postscores else: x1 = self.PCAData.batchs[index].prescores if (self.Shape == self.phenotypes[0]): a = 1 elif (self.Shape == self.phenotypes[1]): a = batch.number elif (self.Shape == self.phenotypes[2]): a = batch.type else: a = 0 if (self.Color == self.phenotypes[0]): b = 0 elif(self.Color == self.phenotypes[1]): b = batch.number elif(self.Color == self.phenotypes[2]): b = batch.type else: b = 0 tmarker = shapes[a] bcolor = self.colors[b] for i in range(len(x1)): points.append((x1[i],y1[i])) plot0 = create_scatter_plot((x1,y1), marker = tmarker, color=getColor(bcolor)) if batch.isSelected: plot0.alpha = 1 else: plot0.alpha = 0.2 plot0.bgcolor = "white" plot0.border_visible = True if index == 0: value_mapper = plot0.value_mapper index_mapper = plot0.index_mapper add_default_grids(plot0) add_default_axes(plot0, vtitle='PCA Indices', htitle='PCA Scores') plot0.index_range.tight_bounds = False plot0.index_range.refresh() plot0.value_range.tight_bounds = False plot0.value_range.refresh() plot0.tools.append(PanTool(plot0)) zoom = ZoomTool(plot0, tool_mode="box", always_on=False, maintain_aspect_ratio=False) plot0.overlays.append(zoom) dragzoom = DragZoom(plot0, drag_button="right", maintain_aspect_ratio=False) plot0.tools.append(dragzoom) else: plot0.value_mapper = value_mapper value_mapper.range.add(plot0.value) plot0.index_mapper = index_mapper index_mapper.range.add(plot0.index) Container.add(plot0) index = index +1 self.RightPlot = Container
def _create_1D1_plot(self): index = 0 plot0 = Plot(self.plotdata, padding=0) plot0.padding_left = 5 plot0.padding_bottom = 5 Container = OverlayPlotContainer(padding=50, fill_padding=True, bgcolor="lightgray", use_backbuffer=True) y1 = range(len(self.PCAData.batchs[0].prescores)) points = [] for batch in self.PCAData.batchs: if (self.active_scores_combobox == "Post Scores"): x1 = self.PCAData.batchs[index].postscores else: x1 = self.PCAData.batchs[index].prescores '''if (self.Shape == self.phenotypes[0]): a = 1 elif (self.Shape == self.phenotypes[1]): a = batch.number elif (self.Shape == self.phenotypes[2]): a = batch.type else: a = 0 if (self.Color == self.phenotypes[0]): b = 0 elif(self.Color == self.phenotypes[1]): b = batch.number elif(self.Color == self.phenotypes[2]): b = batch.type else: b = 0 ''' a = batch.type b = batch.number tmarker = shapes[a] bcolor = self.colors[b] for i in range(len(x1)): points.append((x1[i], y1[i])) plot0 = create_scatter_plot((x1, y1), marker=tmarker, color=getColor(bcolor)) if batch.isSelected: plot0.alpha = 1 plot0.alpha = 1 else: plot0.fill_alpha = 0.2 plot0.edge_alpha = 0.2 plot0.bgcolor = "white" plot0.border_visible = True if index == 0: value_mapper = plot0.value_mapper index_mapper = plot0.index_mapper add_default_grids(plot0) add_default_axes(plot0, vtitle='PCA Indices', htitle='PCA Scores') plot0.index_range.tight_bounds = False plot0.index_range.refresh() plot0.value_range.tight_bounds = False plot0.value_range.refresh() plot0.tools.append(PanTool(plot0)) zoom = ZoomTool(plot0, tool_mode="box", always_on=False, maintain_aspect_ratio=False) plot0.overlays.append(zoom) dragzoom = DragZoom(plot0, drag_button="right", maintain_aspect_ratio=False) plot0.tools.append(dragzoom) else: plot0.value_mapper = value_mapper value_mapper.range.add(plot0.value) plot0.index_mapper = index_mapper index_mapper.range.add(plot0.index) if batch.isSelected: Container.add(plot0) index = index + 1 self.RightPlot = Container
def update_plots(self, waveforms, results): mic_psd = db(psd(waveforms, self.model.fs, 'hanning')).mean(axis=0) results['ref_mic_psd'] = mic_psd[1] results['exp_mic_psd'] = mic_psd[0] results['freq_psd'] = psd_freq(waveforms, self.model.fs) result = MicToneCalibrationResult(**results) frequency = results['frequency'] ds = ArrayPlotData(freq_psd=results['freq_psd'], exp_mic_psd=results['exp_mic_psd'], ref_mic_psd=results['ref_mic_psd'], time=results['time'], exp_mic_waveform=results['exp_mic_waveform'], ref_mic_waveform=results['ref_mic_waveform']) # Set up the waveform plot container = HPlotContainer(bgcolor='white', padding=10) plot = Plot(ds) plot.plot(('time', 'ref_mic_waveform'), color='black') plot.index_range.low_setting = self.model.trim plot.index_range.high_setting = 5.0/frequency+self.model.trim container.add(plot) plot = Plot(ds) plot.plot(('time', 'exp_mic_waveform'), color='red') plot.index_range.low_setting = self.model.trim plot.index_range.high_setting = 5.0/frequency+self.model.trim container.add(plot) result.waveform_plots = container # Set up the spectrum plot plot = Plot(ds) plot.plot(('freq_psd', 'ref_mic_psd'), color='black') plot.plot(('freq_psd', 'exp_mic_psd'), color='red') plot.index_scale = 'log' plot.title = 'Microphone response' plot.padding = 50 plot.index_range.low_setting = 100 plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode='box', always_on=False) plot.overlays.append(zoom) result.spectrum_plots = plot # Plot the fundamental (i.e. the tone) and first even/odd harmonics harmonic_container = HPlotContainer(resizable='hv', bgcolor='white', fill_padding=True, padding=10) for i in range(3): f_harmonic = results['exp_harmonics'][i]['frequency'] plot = Plot(ds) plot.plot(('freq_psd', 'ref_mic_psd'), color='black') plot.plot(('freq_psd', 'exp_mic_psd'), color='red') plot.index_range.low_setting = f_harmonic-500 plot.index_range.high_setting = f_harmonic+500 plot.origin_axis_visible = True plot.padding_left = 10 plot.padding_right = 10 plot.border_visible = True plot.title = 'F{}'.format(i+1) harmonic_container.add(plot) result.harmonic_plots = harmonic_container self.model.tone_data.append(result) # Update the master overview self.model.measured_freq.append(results['frequency']) self.model.measured_spl.append(results['output_spl']) self.model.exp_mic_sens.append(results['exp_mic_sens']) for mic in ('ref', 'exp'): for h in range(3): v = results['{}_harmonics'.format(mic)][h]['mic_rms'] name = 'measured_{}_f{}'.format(mic, h+1) getattr(self.model, name).append(v) v = results['{}_thd'.format(mic)] getattr(self.model, 'measured_{}_thd'.format(mic)).append(v) ds = ArrayPlotData( frequency=self.model.measured_freq, spl=self.model.measured_spl, measured_exp_thd=self.model.measured_exp_thd, measured_ref_thd=self.model.measured_ref_thd, exp_mic_sens=self.model.exp_mic_sens, ) container = VPlotContainer(padding=10, bgcolor='white', fill_padding=True, resizable='hv') plot = Plot(ds) plot.plot(('frequency', 'spl'), color='black') plot.plot(('frequency', 'spl'), color='black', type='scatter') plot.index_scale = 'log' plot.title = 'Speaker output (dB SPL)' container.add(plot) plot = Plot(ds) plot.plot(('frequency', 'measured_ref_thd'), color='black') plot.plot(('frequency', 'measured_ref_thd'), color='black', type='scatter') plot.plot(('frequency', 'measured_exp_thd'), color='red') plot.plot(('frequency', 'measured_exp_thd'), color='red', type='scatter') plot.index_scale = 'log' plot.title = 'Total harmonic distortion (frac)' container.add(plot) plot = Plot(ds) plot.plot(('frequency', 'exp_mic_sens'), color='red') plot.plot(('frequency', 'exp_mic_sens'), color='red', type='scatter') plot.index_scale = 'log' plot.title = 'Experiment mic. sensitivity V (dB re Pa)' container.add(plot) self.model.spl_plots = container