def create_plot_element(self): self.pd = ArrayPlotData(x=np.arange(self.data.size), y=self.data, posx=self.csr_pos, posy=np.array([self.data[self.csr_pos]])) plot = Plot(self.pd) plot.plot(("x", "y"), #type_trait="plot_type", #type='line_scatter_1d', #resizable='', title='', #x_label="Time", y_label="Signal", color=tuple(cbrewer[np.random.randint(0,10)]), bgcolor="grey", border_visible=True, border_width=1, #padding_bg_color="lightgray", width=800, height=380, marker_size=2, show_label=False) plot.plot_1d("posx", #type="scatter", type="line_scatter_1d", name="dot", color="red", #color_mapper=self._cmap(image_value_range), marker="circle", marker_size=4) self.pd.set_data('x', np.arange(self.data.size)) self.pd.set_data('y', self.data) self.pd.set_data('posx', self.csr_pos) self.pd.set_data('posy', np.array([self.data[self.csr_pos]])) self.plot = plot
def test_range_change(self): arr = arange(10) data = ArrayPlotData(x=arr, y=arr) plot = Plot(data) renderer_2d = plot.plot(('x', 'y'))[0] renderer_1d = plot.plot_1d(('x'))[0] new_range = DataRange1D() old_range = plot.index_range self.assertIsNot(old_range, new_range) self.assertIs(renderer_2d.index_range, old_range) self.assertIs(renderer_1d.index_range, old_range) plot.index_range = new_range self.assertIs(plot.index_range, new_range) self.assertIs(renderer_2d.index_range, new_range) self.assertIs(renderer_1d.index_range, new_range)
def _create_plot_component(): # Create some data numpts = 50 x = sort(random(numpts)) y = random(numpts) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Create the plot plot = Plot(pd, use_backbuffer=True, auto_grid=False) plot.plot_1d( 'index', type='line_scatter_1d', orientation='h', color='lightgrey', line_style='dot', ) plot.plot_1d( 'index', type='scatter_1d', orientation='h', marker='plus', alignment='bottom' ) plot.plot_1d( 'value', type='line_scatter_1d', orientation='v', color='lightgrey', line_style='dot', ) plot.plot_1d( 'value', type='scatter_1d', orientation='v', marker='plus', alignment='left' ) plot.plot(("index", "value"), type="scatter", marker="square", index_sort="ascending", color="orange", marker_size=3, #randint(1,5, numpts), bgcolor="white", use_backbuffer=True) # Tweak some of the plot properties plot.title = "1D Scatter Plots" plot.line_width = 0.5 plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot, constrain_key="shift")) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create some data numpts = 50 x = sort(random(numpts)) y = random(numpts) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Create the plot plot = Plot(pd, use_backbuffer=True, auto_grid=False) plot.plot_1d( 'index', type='line_scatter_1d', orientation='h', color='lightgrey', line_style='dot', ) plot.plot_1d( 'index', type='scatter_1d', orientation='h', marker='plus', alignment='bottom') plot.plot_1d( 'value', type='line_scatter_1d', orientation='v', color='lightgrey', line_style='dot', ) plot.plot_1d( 'value', type='scatter_1d', orientation='v', marker='plus', alignment='left') plot.plot( ("index", "value"), type="scatter", marker="square", index_sort="ascending", color="orange", marker_size=3, #randint(1,5, numpts), bgcolor="white", use_backbuffer=True) # Tweak some of the plot properties plot.title = "1D Scatter Plots" plot.line_width = 0.5 plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot, constrain_key="shift")) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
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