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, padding=50) plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red") plot1.plot(("index", "y3"), name="j_3", color="blue") # 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) # Add the scrollbar hscrollbar = PlotScrollBar(component=plot1, axis="index", resizable="h", height=15) plot1.padding_top = 0 hscrollbar.force_data_update() # Create a container and add our plots container = VPlotContainer() container.add(plot1) container.add(hscrollbar) return container
def _create_plot_component(): # Create a GridContainer to hold all of our plots: 2 rows, 3 columns: container = GridContainer(padding=40, fill_padding=True, bgcolor="lightgray", use_backbuffer=True, shape=(2, 3), spacing=(20, 20)) # Create the initial series of data x = linspace(-5, 15.0, 100) pd = ArrayPlotData(index=x) # Plot some bessel functions and add the plots to our container for i in range(6): pd.set_data("y" + str(i), jn(i, x)) plot = Plot(pd) plot.plot(("index", "y" + str(i)), color=tuple(COLOR_PALETTE[i]), line_width=2.0, bgcolor="white", border_visible=True) # Tweak some of the plot properties plot.border_width = 1 plot.padding = 0 plot.padding_top = 30 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Add to the grid container ( container.add(plot) # Set the upper-left plot to only be resizable vertically, and to have a # fixed horizontal width. This also constrains the width of the first column. ul_plot = container.components[0] ul_plot.set(resizable="v", width=200) ul_plot.overlays.append( PlotLabel("Not horizontally resizable", component=ul_plot)) # Set the bottom center plot to have a fixed width and height. # This also constrains the height of the bottom row and the width of # the middle column. cplot = container.components[4] cplot.set(resizable="", bounds=[400, 400]) cplot.overlays.append(PlotLabel("Not resizable", component=cplot)) container.padding_top = 50 container.overlays.append( PlotLabel( 'Resize the window - some plots resize, others cannot ' '(see source code)', component=container, font="swiss 16", overlay_position="top")) return container
def __init__(self): super(HHCurrentTraits, self).__init__() # gates self.vm = linspace(-120,65,1000) (M, N, H) = self.__gates() nA = self.__iv() self.gatedata = ArrayPlotData(x=self.vm, M=M, N=N, H=H) self.ivdata = ArrayPlotData(x=self.vm, nA=nA) gateplot = Plot(self.gatedata) gateplot.plot(("x", "M"), type = "line", color = "blue") gateplot.plot(("x", "N"), type = "line", color = "green") gateplot.plot(("x", "H"), type = "line", color = "red") ivplot = Plot(self.ivdata) ivplot.plot(("x", "nA"), type = "line", color = "black") container = VPlotContainer(ivplot, gateplot) container.spacing = 0 gateplot.x_axis.orientation = "top" gateplot.padding_bottom = 0 ivplot.padding_top = 0 self.plots = container
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, padding=50) plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red") plot1.plot(("index", "y3"), name="j_3", color="blue") # 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) # Add the scrollbar hscrollbar = PlotScrollBar(component=plot1, axis="index", resizable="h", height=15) plot1.padding_top = 0 hscrollbar.force_data_update() # Create a container and add our plots container = VPlotContainer() container.add(plot1) container.add(hscrollbar) 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 a GridContainer to hold all of our plots: 2 rows, 3 columns: container = GridContainer(padding=40, fill_padding=True, bgcolor="lightgray", use_backbuffer=True, shape=(2,3), spacing=(20,20)) # Create the initial series of data x = linspace(-5, 15.0, 100) pd = ArrayPlotData(index = x) # Plot some bessel functions and add the plots to our container for i in range(6): pd.set_data("y" + str(i), jn(i,x)) plot = Plot(pd) plot.plot(("index", "y" + str(i)), color=tuple(COLOR_PALETTE[i]), line_width=2.0, bgcolor = "white", border_visible=True) # Tweak some of the plot properties plot.border_width = 1 plot.padding = 0 plot.padding_top = 30 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Add to the grid container ( container.add(plot) # Set the upper-left plot to only be resizable vertically, and to have a # fixed horizontal width. This also constrains the width of the first column. ul_plot = container.components[0] ul_plot.set(resizable="v", width=200) ul_plot.overlays.append(PlotLabel("Not horizontally resizable", component=ul_plot)) # Set the bottom center plot to have a fixed width and height. # This also constrains the height of the bottom row and the width of # the middle column. cplot = container.components[4] cplot.set(resizable="", bounds=[400,400]) cplot.overlays.append(PlotLabel("Not resizable", component=cplot)) container.padding_top = 50 container.overlays.append( PlotLabel('Resize the window - some plots resize, others cannot ' '(see source code)', component=container, font = "swiss 16", overlay_position = "top")) return container
def __init__(self, ExprmntVm=None, ExprmntnA=None): super(HHCurrentTraits, self).__init__() # gates self.vm = linspace(-120,65,1000) ((MCur1,NCur1,HCur1),(MCur2,NCur2,HCur2)) = self.__gates() self.Cur1gatedata = ArrayPlotData(x=self.vm, M=MCur1, N=NCur1, H=HCur1) self.Cur2gatedata = ArrayPlotData(x=self.vm, M=MCur2, N=NCur2, H=HCur2) Cur1gatesplot = Plot(self.Cur1gatedata) Cur1gatesplot.plot(("x", "M"), type = "line", color = "blue") Cur1gatesplot.plot(("x", "N"), type = "line", color = "green") Cur1gatesplot.plot(("x", "H"), type = "line", color = "red") Cur2gatesplot = Plot(self.Cur2gatedata) Cur2gatesplot.plot(("x", "M"), type = "line", color = "blue") Cur2gatesplot.plot(("x", "N"), type = "line", color = "green") Cur2gatesplot.plot(("x", "H"), type = "line", color = "red") (Cur1,Cur2) = self.__iv() self.ivdata = ArrayPlotData(x=self.vm, nA1=Cur1, nA2=Cur2, combin=Cur1+Cur2) ivplot = Plot(self.ivdata) ivplot.plot(("x", "nA1"), type = "line", color = "blue") ivplot.plot(("x", "nA2"), type = "line", color = "green") ivplot.plot(("x", "combin"), type = "line", color = "black") if ExprmntVm is not None: self.ivdata.set_data('ExptVm',ExprmntVm) self.ivdata.set_data('ExptnA',ExprmntnA) ivplot.plot(("ExptVm", "ExptnA"), type = "scatter", color = "red", marker_size = 5) self.plots = VPlotContainer(ivplot, Cur2gatesplot, Cur1gatesplot) self.plots.spacing = 0 ivplot.padding_top = 0 Cur1gatesplot.padding_bottom = 0 Cur2gatesplot.padding_top = 0 self.write_button = Button(label="Print_Pars")
def intensity_histogram_plot_component(self): data = ArrayPlotData(x=self.bin_edges, y=self.hist) plot = Plot(data) plot.plot( ('x', "y"), type='bar', color='auto', bar_width=1, ) # without padding plot just doesn't seem to show up? plot.border_width = 0 plot.padding = 0 plot.padding_top = 0 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") # Tweak some of the plot properties plot1.title = "My First Line Plot" plot1.padding = 50 plot1.padding_top = 75 plot1.legend.visible = True x = linspace(-5, 15.0, 100) y = jn(5, x) foreign_plot = create_line_plot((x, y), color=tuple(COLOR_PALETTE[0]), width=2.0) left, bottom = add_default_axes(foreign_plot) left.orientation = "right" bottom.orientation = "top" plot1.add(foreign_plot) # Attach some tools to the plot broadcaster = BroadcasterTool() broadcaster.tools.append(PanTool(plot1)) broadcaster.tools.append(PanTool(foreign_plot)) for c in (plot1, foreign_plot): zoom = ZoomTool(component=c, tool_mode="box", always_on=False) broadcaster.tools.append(zoom) plot1.tools.append(broadcaster) return plot1
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") # Tweak some of the plot properties plot1.title = "My First Line Plot" plot1.padding = 50 plot1.padding_top = 75 plot1.legend.visible = True x = linspace(-5, 15.0, 100) y = jn(5, x) foreign_plot = create_line_plot((x,y), color=tuple(COLOR_PALETTE[0]), width=2.0) left, bottom = add_default_axes(foreign_plot) left.orientation = "right" bottom.orientation = "top" plot1.add(foreign_plot) # Attach some tools to the plot broadcaster = BroadcasterTool() broadcaster.tools.append(PanTool(plot1)) broadcaster.tools.append(PanTool(foreign_plot)) for c in (plot1, foreign_plot): zoom = ZoomTool(component=c, tool_mode="box", always_on=False) broadcaster.tools.append(zoom) plot1.tools.append(broadcaster) return plot1
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