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 _plot_default(self): data = self.data < self.limit pd = self.pd = ArrayPlotData(imagedata=data,orig=self.data) plot1 = Plot(pd, default_origin='top left') plot2 = Plot(pd, default_origin='top left') img_plot1 = plot1.img_plot("imagedata",colormap=gray,padding=0)[0] img_plot2 = plot2.img_plot("orig",colormap=gray,padding=0)[0] container = HPlotContainer(plot1,plot2) container.spacing=0 plot1.padding_right=0 plot2.padding_left=0 plot2.y_axis.orientation= 'right' return container
def __init__(self): # Create the data and the PlotData object x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) # Create the scatter plot scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") # Create the line plot line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") # Create a horizontal container and put the two plots inside it container = HPlotContainer(scatter, line) container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis.orientation = "right" self.plot = container
def _plot_default(self): # Create the data and the PlotData object x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x = x, y = y) # Create the scatter plot scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") # Create the line plot line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") # Create a horizontal container and put the two plots inside it container = HPlotContainer(scatter, line) container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis.orientation = "right" return container
def _plot_default(self): x = linspace(-14, 14, 100) y = sin(x) * x**3 plotdata = ArrayPlotData(x=x, y=y) scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") container = HPlotContainer(scatter, line) container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis_orientation = "right" return container
def __init__(self): super(ContainerExample, self).__init__() x = linspace(-14, 14, 100) y = sin(x) * x ** 3 plotdata = ArrayPlotData(x=x, y=y) scatter = Plot(plotdata) scatter.plot(("x", "y"), type="scatter", color="blue") line = Plot(plotdata) line.plot(("x", "y"), type="line", color="blue") container = HPlotContainer(scatter, line) #Making the plots touch in the middle container.spacing = 0 scatter.padding_right = 0 line.padding_left = 0 line.y_axis.orientation = "right" self.plot = container
def _create_plot_component(): army_lat = np.column_stack([army['start_lat'], army['end_lat']]).reshape(-1) army_lon = np.column_stack([army['start_lon'], army['end_lon']]).reshape(-1) plot_data = ArrayPlotData( army_lon=army_lon, army_lat=army_lat, army_size=army['size'], army_color=army['direction'] * army["group"], towns_lat=towns['lat'], towns_lon=towns['lon'], towns=towns['town'], temp_lon=temperatures['lon'], temp=temperatures['temp'], temp_date=temperatures['date'], ) map_plot = Plot(plot_data) map_plot.x_grid = None map_plot.y_grid = None map_plot.x_axis.orientation = 'top' map_plot.x_axis.title = 'Longitude' map_plot.y_axis.title = 'Latitude' map_plot.title = "Minard's Map of Napoleon's Russian Campaign" map_plot._title.overlay_position = "inside top" map_plot._title.hjustify = "left" map_plot._title.vjustify = "bottom" map_plot.plot( ("army_lon", "army_lat", "army_color", "army_size"), type="cmap_segment", name="my_plot", color_mapper=viridis, border_visible=True, bgcolor="white", size_min=1.0, size_max=128.0, ) map_plot.plot( ("towns_lon", "towns_lat"), type="scatter", ) map_plot.plot( ("towns_lon", "towns_lat", "towns"), type="text", text_margin=4, h_position='right', text_offset=(4, 0), ) map_plot.plot_1d( ('temp_lon'), type='line_scatter_1d', alpha=0.5, line_style='dot', ) map_plot.index_range.high_setting = 38 map_plot.index_range.low_setting = 23 map_plot.value_range.high_setting = 56.0 map_plot.value_range.low_setting = 53.5 map_plot.tools.extend([ PanTool(map_plot), ZoomTool(map_plot), ]) temp_plot = Plot(plot_data, height=100) temp_plot.index_range = map_plot.index_range temp_plot.x_grid = None temp_plot.x_axis = None temp_plot.y_axis.orientation = 'right' temp_plot.y_axis.title = u'Temp (°Re)' temp_plot.plot( ('temp_lon', 'temp'), type='line', ) temp_plot.plot_1d( ('temp_lon'), type='line_scatter_1d', alpha=0.5, line_style='dot', ) temp_plot.plot_1d( ('temp_lon', 'temp_date'), type='textplot_1d', alpha=0.5, line_style='dot', alignment='bottom', ) temp_plot.value_range.high_setting = 5 temp_plot.value_range.low_setting = -35 container = VPlotContainer(temp_plot, map_plot) container.spacing = 0 map_plot.padding_bottom = 0 map_plot.padding_left = 70 map_plot.padding_right = 70 map_plot.padding_top = 50 temp_plot.padding_top = 0 temp_plot.padding_bottom = 15 temp_plot.padding_right = 70 temp_plot.padding_left = 70 temp_plot.height = 100 temp_plot.resizable = 'h' return 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