def _plot_default(self): # Set up the spectrum plot spectrum_plot = Plot(self.spectrum_data) spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum", color="red") spectrum_plot.padding = 50 spectrum_plot.title = "Spectrum" spec_range = list( spectrum_plot.plots.values())[0][0].value_mapper.range # noqa spec_range.low = 0.0 spec_range.high = 5.0 spectrum_plot.index_axis.title = 'Frequency (Hz)' spectrum_plot.value_axis.title = 'Amplitude' # Time series plot time_plot = Plot(self.time_data) time_plot.plot(("time", "amplitude"), name="Time", color="blue") time_plot.padding = 50 time_plot.title = "Time" time_plot.index_axis.title = 'Time (seconds)' time_plot.value_axis.title = 'Amplitude' time_range = list(time_plot.plots.values())[0][0].value_mapper.range time_range.low = -0.2 time_range.high = 0.2 # Spectrogram plot spectrogram_plot = Plot(self.spectrogram_plotdata) max_time = SPECTROGRAM_LENGTH * NUM_SAMPLES / SAMPLING_RATE max_freq = SAMPLING_RATE / 2 spectrogram_plot.img_plot( 'imagedata', name='Spectrogram', xbounds=(0, max_time), ybounds=(0, max_freq), colormap=hot, ) range_obj = spectrogram_plot.plots['Spectrogram'][0].value_mapper.range range_obj.high = 5 range_obj.low = 0.0 spectrogram_plot.title = 'Spectrogram' container = HPlotContainer() container.add(spectrum_plot) container.add(time_plot) container.add(spectrogram_plot) return container
def _create_plot_component(): # Create some data index, sorted_vals = _create_data(200) # Create a plot data obect and give it this data pd = ArrayPlotData(index = index, min = sorted_vals[0], bar_min = sorted_vals[1], average = sorted_vals[2], bar_max = sorted_vals[3], max = sorted_vals[4]) # Create the plot plot = Plot(pd) plot.candle_plot(("index", "min", "bar_min", "average", "bar_max", "max"), color = "lightgray", bar_line_color = "black", stem_color = "blue", center_color = "red", center_width = 2) # Tweak some of the plot properties plot.title = "Candlestick Plot" 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 a GridContainer to hold all of our plots container = GridContainer(padding=20, fill_padding=True, bgcolor="lightgray", use_backbuffer=True, shape=(3,3), spacing=(12,12)) # 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(9): 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 = 10 # Set each plot's aspect ratio based on its position in the # 3x3 grid of plots. n,m = divmod(i, 3) plot.aspect_ratio = float(n+1) / (m+1) # 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) return container
def _plot_default(self): self.data = self._data_default() plot = Plot(self.data) for ii, s_name in enumerate(self._samples): color = COLORS[ii % len(self._samples)] plot.plot( ("bins", s_name), name=s_name, type="filled_line", edge_color=color, face_color=color, alpha=0.5, bgcolor="white", render_style="hold", ) # render_style determines whether interpolate plot.index = plot._get_or_create_datasource("bins") # set index name manually so range selection works plot.index_scale = "log" plot.title = "Fermi Plot" plot.padding = 50 plot.legend.visible = True plot.tools.append(PanTool(plot)) plot.active_tool = RangeSelection(plot) plot.overlays.append(RangeSelectionOverlay(component=plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create a scalar field to colormap xs = linspace(0, 10, 600) ys = linspace(0, 5, 600) x, y = meshgrid(xs,ys) z = exp(-(x**2+y**2)/100) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", z) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata", xbounds=(0, 10), ybounds=(0, 5), colormap=jet)[0] # Tweak some of the plot properties plot.title = "My First Image Plot" plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False) img_plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create some data numpts = 5000 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) # Tweak some of the plot properties plot.title = "Scatter Plot" 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 _pot_plot_default(self): plot = Plot(self.plot_data) plot.plot(('potentiometer',)) plot.padding = (0, 0, 0, 0) plot.value_mapper.range.low_setting = 0 plot.value_mapper.range.high_setting = 1 return plot
def _acc_x_plot_default(self): plot = Plot(self.plot_data) plot.plot(('acc_x',)) plot.padding = (0, 0, 0, 0) plot.value_mapper.range.low_setting = 0 plot.value_mapper.range.high_setting = 1 return plot
def _create_plot_component(): # Create a scalar field to colormap xbounds = (-2 * pi, 2 * pi, 600) ybounds = (-1.5 * pi, 1.5 * pi, 300) xs = linspace(*xbounds) ys = linspace(*ybounds) x, y = meshgrid(xs, ys) z = sin(x) * y # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", z) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata", xbounds=xbounds[:2], ybounds=ybounds[:2], colormap=viridis)[0] # Tweak some of the plot properties plot.title = "Image Plot with Lasso" plot.padding = 50 lasso_selection = LassoSelection(component=img_plot) lasso_selection.on_trait_change(lasso_updated, "disjoint_selections") lasso_overlay = LassoOverlay(lasso_selection=lasso_selection, component=img_plot) img_plot.tools.append(lasso_selection) img_plot.overlays.append(lasso_overlay) return plot
def _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.x_grid = None plot.y_grid = None plot.padding = 0 plot.plot(('x', 'image_histogram'), render_style='connectedhold') plot.plot(('x', 'mapped_histogram'), type='filled_line', fill_color='yellow', render_style='connectedhold', name='mapped_histogram') intercept_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='intercept') slope_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='slope', modifier_keys=set(['shift'])) gamma_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='gamma', modifier_keys=set(['control'])) plot.tools += [intercept_tool, slope_tool, gamma_tool] intercept_overlay = SimpleInspectorOverlay(component=plot, align='ul', inspector=intercept_tool, field_formatters=[[basic_formatter('Intercept', 2)]] ) slope_overlay = SimpleInspectorOverlay(component=plot, align='ul', inspector=slope_tool, field_formatters=[[basic_formatter('Slope', 2)]] ) gamma_overlay = SimpleInspectorOverlay(component=plot, align='ul', inspector=gamma_tool, field_formatters=[[basic_formatter('Gamma', 2)]] ) plot.overlays += [intercept_overlay, slope_overlay, gamma_overlay] return plot
def _create_plot_component(): # Create some x-y data series to plot x = linspace(1.0, 8.0, 200) pd = ArrayPlotData(index = x) pd.set_data("y0", sqrt(x)) pd.set_data("y1", x) pd.set_data("y2", x**2) pd.set_data("y3", exp(x)) pd.set_data("y4", gamma(x)) pd.set_data("y5", x**x) # Create some line plots of some of the data plot = Plot(pd) plot.plot(("index", "y0"), line_width=2, name="sqrt(x)", color="purple") plot.plot(("index", "y1"), line_width=2, name="x", color="blue") plot.plot(("index", "y2"), line_width=2, name="x**2", color="green") plot.plot(("index", "y3"), line_width=2, name="exp(x)", color="gold") plot.plot(("index", "y4"), line_width=2, name="gamma(x)",color="orange") plot.plot(("index", "y5"), line_width=2, name="x**x", color="red") # Set the value axis to display on a log scale plot.value_scale = "log" # Tweak some of the plot properties plot.title = "Log Plot" plot.padding = 50 plot.legend.visible = True # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create some data index, vals = _create_data(20) # Create a plot data object and give it this data pd = ArrayPlotData(index = index, values = vals) # Create the plot plot = Plot(pd) plot.stacked_bar_plot(("index", "values"), color = ["red", "yellow", "green", "blue"], outline_color = "lightgray",) # Tweak some of the plot properties plot.title = "Stacked Bar Plot" 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 = 5000 x = sort(random(numpts)) y = random(numpts) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Create the plot plot = Plot(pd) plot.plot(("index", "value"), type="scatter", marker="circle", index_sort="ascending", color="orange", marker_size=3, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot" 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(obj): # Spectrogram plot obj.data = fr.getDataSets(".chi") frequencies = obj.data[0][0] index = ArrayDataSource(data=frequencies) values = [obj.data[i][1] for i in xrange(len(obj.data))] print len(obj.data[1][1]) print len(obj.data) p = WaterfallRenderer( index=index, values=values, index_mapper=LinearMapper(range=DataRange1D(low=0, high=SPECTROGRAM_LENGTH)), value_mapper=LinearMapper(range=DataRange1D(low=0, high=SPECTROGRAM_LENGTH)), x2_mapper=LinearMapper(low_pos=0, high_pos=100, range=DataRange1D(low=10.0, high=101.0)), y2_mapper=LinearMapper(low_pos=0, high_pos=100, range=DataRange1D(low=0, high=600000)), ) spectrogram_plot = p obj.spectrogram_plot = p dummy = Plot() dummy.padding = 50 dummy.index_axis.mapper.range = p.index_mapper.range dummy.index_axis.title = "Frequency (hz)" dummy.add(p) c2 = VPlotContainer() c2.add(dummy) return c2
def _create_plot_component(): # Create some data numpts = 1000 x = sort(random(numpts)) y = random(numpts) color = randint(0, 7, numpts) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("color", color) # Create the plot plot = Plot(pd) plot.plot(("index", "value", "color"), type="cmap_scatter", name="my_plot", color_mapper=accent, marker="square", fill_alpha=0.5, marker_size=6, outline_color="black", border_visible=True, bgcolor="white") # Tweak some of the plot properties plot.title = "Colormapped Scatter Plot with Range-selectable Data Points" plot.padding = 50 plot.x_grid.visible = False plot.y_grid.visible = False plot.x_axis.font = "modern 16" plot.y_axis.font = "modern 16" # Right now, some of the tools are a little invasive, and we need the # actual ColomappedScatterPlot object to give to them cmap_renderer = plot.plots["my_plot"][0] # 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) selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35, selection_type="mask") cmap_renderer.overlays.append(selection) # Create the colorbar, handing in the appropriate range and colormap colorbar = create_colorbar(plot.color_mapper) colorbar.plot = cmap_renderer colorbar.padding_top = plot.padding_top colorbar.padding_bottom = plot.padding_bottom # Create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer=True) container.add(plot) container.add(colorbar) container.bgcolor = "lightgray" return container
def _create_plot_component(): # Create some data numpts = 500 x1 = random(numpts) y1 = random(numpts) x2 = x1 + standard_normal(numpts) * 0.05 y2 = y1 + standard_normal(numpts) * 0.05 # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("index", column_stack([x1, x2]).reshape(-1)) pd.set_data("value", column_stack([y1, y2]).reshape(-1)) # Create the plot plot = Plot(pd) plot.plot(("index", "value"), type="segment", color="forestgreen", line_width=2, line_style='dash', alpha=0.7, bgcolor="white") # Tweak some of the plot properties plot.title = "Segment Plot" 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 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 _create_plot_component(): # Create some x-y data series (with NaNs) to plot x = linspace(-5.0, 15.0, 500) x[75:125] = nan x[200:250] = nan x[300:330] = nan pd = ArrayPlotData(index = x) pd.set_data("value1", jn(0, x)) pd.set_data("value2", jn(1, x)) # Create some line and scatter plots of the data plot = Plot(pd) plot.plot(("index", "value1"), name="j_0(x)", color="red", width=2.0) plot.plot(("index", "value2"), type="scatter", marker_size=1, name="j_1(x)", color="green") # Tweak some of the plot properties plot.title = "Plots with NaNs" plot.padding = 50 plot.legend.visible = True # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): pd = ArrayPlotData(x=random(100), y=random(100)) # Create some line plots of some of the data plot = Plot(pd) # Create a scatter plot and get a reference to it (separate from the # Plot object) because we'll need it for the regression tool below. scatterplot = plot.plot(("x", "y"), color="blue", type="scatter")[0] # Tweak some of the plot properties plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot, drag_button="right")) plot.overlays.append(ZoomTool(plot)) # Add the regression tool and overlay. These need to be added # directly to the scatterplot instance (and not the Plot instance). regression = RegressionLasso(scatterplot, selection_datasource=scatterplot.index) scatterplot.tools.append(regression) scatterplot.overlays.append( RegressionOverlay(scatterplot, lasso_selection=regression)) return plot
def _create_plot_component(): # Create some x-y data series to plot x = linspace(1.0, 8.0, 200) pd = ArrayPlotData(index=x) pd.set_data("y0", sqrt(x)) pd.set_data("y1", x) pd.set_data("y2", x**2) pd.set_data("y3", exp(x)) pd.set_data("y4", gamma(x)) pd.set_data("y5", x**x) # Create some line plots of some of the data plot = Plot(pd) plot.plot(("index", "y0"), line_width=2, name="sqrt(x)", color="purple") plot.plot(("index", "y1"), line_width=2, name="x", color="blue") plot.plot(("index", "y2"), line_width=2, name="x**2", color="green") plot.plot(("index", "y3"), line_width=2, name="exp(x)", color="gold") plot.plot(("index", "y4"), line_width=2, name="gamma(x)", color="orange") plot.plot(("index", "y5"), line_width=2, name="x**x", color="red") # Set the value axis to display on a log scale plot.value_scale = "log" # Tweak some of the plot properties plot.title = "Log Plot" plot.padding = 50 plot.legend.visible = True # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component():# Create a scalar field to colormap xbounds = (-2*pi, 2*pi, 600) ybounds = (-1.5*pi, 1.5*pi, 300) xs = linspace(*xbounds) ys = linspace(*ybounds) x, y = meshgrid(xs,ys) z = sin(x)*y # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", z) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata", xbounds = xbounds[:2], ybounds = ybounds[:2], colormap=jet)[0] # Tweak some of the plot properties plot.title = "My First Image Plot" plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) imgtool = ImageInspectorTool(img_plot) img_plot.tools.append(imgtool) overlay = ImageInspectorOverlay(component=img_plot, image_inspector=imgtool, bgcolor="white", border_visible=True) img_plot.overlays.append(overlay) return plot
def _plot_default(self): self.data = self._data_default() plot = Plot(self.data) for ii, s_name in enumerate(self._samples): color = COLORS[ii % len(self._samples)] plot.plot(('bins',s_name), name=s_name, type='filled_line', edge_color=color, face_color=color, alpha=0.5, bgcolor='white', render_style='hold') # render_style determines whether interpolate plot.index = plot._get_or_create_datasource('bins') #set index name manually so range selection works plot.index_scale = 'log' plot.title = 'Fermi Plot' plot.padding = 50 plot.legend.visible = True plot.tools.append(PanTool(plot)) plot.active_tool = RangeSelection(plot) plot.overlays.append(RangeSelectionOverlay(component=plot)) zoom = ZoomTool(component=plot, tool_mode='box', always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Use n_gon to compute center locations for our polygons points = n_gon(center=(0,0), r=3, nsides=4) # Choose some colors for our polygons colors = {3:0xaabbcc, 4:'orange', 5:'yellow', 6:'lightgreen'} # Create a PlotData object to store the polygon data pd = ArrayPlotData() # Create a Polygon Plot to draw the regular polygons polyplot = Plot(pd) # Store path data for each polygon, and plot nsides = 3 for p in points: npoints = n_gon(center=p, r=2, nsides=nsides) nxarray, nyarray = transpose(npoints) pd.set_data("x" + str(nsides), nxarray) pd.set_data("y" + str(nsides), nyarray) plot = polyplot.plot(("x"+str(nsides), "y"+str(nsides)), type="polygon", face_color=colors[nsides], hittest_type="poly")[0] plot.tools.append(DataspaceMoveTool(plot, drag_button="left")) nsides = nsides + 1 # Tweak some of the plot properties polyplot.padding = 50 polyplot.title = "Polygon Plot" polyplot.x_axis.mapper.range.set(low=-10, high=10) polyplot.y_axis.mapper.range.set(low=-10, high=10) return polyplot
def updateplots(self): x = np.sort(np.random.random(100)) y = np.random.random(100) color = np.exp(-(x ** 2 + y ** 2)) # np.random.random(100) pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("color", color) # Create some line plots of some of the data plot = Plot(pd) # Create a scatter plot and get a reference to it (separate from the # Plot object) because we'll need it for the regression tool below. scatterplot = plot.plot( ("index", "value", "color"), type="cmap_scatter", color_mapper=reverse(Spectral), marker="square", fill_alpha=0.9, marker_size=6, bgcolor=QtGui.QColor(240, 240, 240), )[0] # Tweak some of the plot properties plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot, drag_button="right")) plot.overlays.append(ZoomTool(plot)) # Add the regression tool and overlay. These need to be added # directly to the scatterplot instance (and not the Plot instance). regression = RegressionLasso(scatterplot, selection_datasource=scatterplot.index) scatterplot.tools.append(regression) scatterplot.overlays.append(RegressionOverlay(scatterplot, lasso_selection=regression)) self.chaco_widget1.visualization.plot = plot self.chaco_widget2.visualization.plot = plot
def _create_plot_component(): pd = ArrayPlotData(x=random(100), y=random(100)) # Create some line plots of some of the data plot = Plot(pd) # Create a scatter plot and get a reference to it (separate from the # Plot object) because we'll need it for the regression tool below. scatterplot = plot.plot(("x", "y"), color="blue", type="scatter")[0] # Tweak some of the plot properties plot.padding = 50 # Attach some tools to the plot plot.tools.append(PanTool(plot, drag_button="right")) plot.overlays.append(ZoomTool(plot)) # Add the regression tool and overlay. These need to be added # directly to the scatterplot instance (and not the Plot instance). regression = RegressionLasso(scatterplot, selection_datasource=scatterplot.index) scatterplot.tools.append(regression) scatterplot.overlays.append(RegressionOverlay(scatterplot, lasso_selection=regression)) return plot
def _pot_plot_default(self): plot = Plot(self.plot_data) plot.plot(('potentiometer', )) plot.padding = (0, 0, 0, 0) plot.value_mapper.range.low_setting = 0 plot.value_mapper.range.high_setting = 1 return plot
def _acc_y_plot_default(self): plot = Plot(self.plot_data) plot.plot(('acc_y', )) plot.padding = (0, 0, 0, 0) plot.value_mapper.range.low_setting = 0 plot.value_mapper.range.high_setting = 1 return plot
def _fuel_cycle_plot_component(x, y, x_name, y_name): # Create some data # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Create the plot plot = Plot(pd) plot.plot(("index", "value"), type="line", marker="circle", index_sort="ascending", color="red", marker_size=3, bgcolor="white") # Tweak some of the plot properties plot.title = "Fuel Cycle Plot" plot.line_width = 0.5 plot.padding = 100 plot.x_axis.title = x_name plot.x_axis.title_font = "Roman 16" plot.x_axis.tick_label_font = "Roman 12" plot.y_axis.title = y_name plot.y_axis.title_font = "Roman 16" plot.y_axis.tick_label_font = "Roman 12" # Attach some tools to the plot plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) return plot
def _create_plot_component(): # Create some data numpts = 1000 x = numpy.arange(0, numpts) y = numpy.random.random(numpts) marker_size = numpy.random.normal(4.0, 4.0, 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) plot.plot(("index", "value"), type="scatter", marker="circle", index_sort="ascending", color=(1.0, 0.0, 0.74, 0.4), marker_size=marker_size, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot" 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 a scalar field to colormap xbounds = (-2 * pi, 2 * pi, 600) ybounds = (-1.5 * pi, 1.5 * pi, 300) xs = linspace(*xbounds) ys = linspace(*ybounds) x, y = meshgrid(xs, ys) z = sin(x) * y # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", z) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata", xbounds=xbounds[:2], ybounds=ybounds[:2], colormap=jet)[0] # Tweak some of the plot properties plot.title = "Image Plot with Lasso" plot.padding = 50 lasso_selection = LassoSelection(component=img_plot) lasso_selection.on_trait_change(lasso_updated, "disjoint_selections") lasso_overlay = LassoOverlay(lasso_selection=lasso_selection, component=img_plot) img_plot.tools.append(lasso_selection) img_plot.overlays.append(lasso_overlay) return plot
def _create_plot_component(): # Create some data numpts = 1000 x = numpy.arange(0, numpts) y = numpy.random.random(numpts) marker_size = numpy.random.normal(4.0, 4.0, numpts) color = numpy.random.random(numpts) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Because this is a non-standard renderer, we can't call plot.plot, which # sets up the array data sources, mappers and default index/value ranges. # So, its gotta be done manually for now. index_ds = ArrayDataSource(x) value_ds = ArrayDataSource(y) color_ds = ArrayDataSource(color) # Create the plot plot = Plot(pd) plot.index_range.add(index_ds) plot.value_range.add(value_ds) # Create the index and value mappers using the plot data ranges imapper = LinearMapper(range=plot.index_range) vmapper = LinearMapper(range=plot.value_range) # Create the scatter renderer scatter = ColormappedScatterPlot( index=index_ds, value=value_ds, color_data=color_ds, color_mapper=jet(range=DataRange1D( low=0.0, high=1.0)), fill_alpha=0.4, index_mapper=imapper, value_mapper=vmapper, marker='circle', marker_size=marker_size) # Append the renderer to the list of the plot's plots plot.add(scatter) plot.plots['var_size_scatter'] = [scatter] # Tweak some of the plot properties plot.title = "Variable Size and Color Scatter Plot" 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(self): """ Creates the plot component of the to be used in the FeatureScatter instance. """ x = np.zeros(len(self.data)) y = np.zeros(len(self.data)) c = np.zeros(len(self.data)) for i, (coord, count) in enumerate(self.data.items()): x[i], y[i] = coord c[i] = count c = np.log2(c) pd = ArrayPlotData() pd.set_data("x", x) pd.set_data("y", y) pd.set_data("color", c) cm = Map(DataRange1D(low=-c.max() / 2, high=c.max())) plot = Plot(pd) plot.plot(("x", "y", "color"), type="cmap_scatter", name="my_plot", marker="dot", index_sort="ascending", color_mapper=cm, marker_size=2, bgcolor=0xF7F7F7, ) plot.title = "Scatter Plot With Lasso Selection" plot.line_width = 1 plot.padding = 50 my_plot = plot.plots["my_plot"][0] my_plot.data = self.data my_plot.out_file = self.out_file my_plot.label = self.label lasso_selection = FeatureLasso(component=my_plot, selection_datasource=my_plot.index, drag_button="left") my_plot.tools.append(lasso_selection) my_plot.tools.append(BetterZoom(my_plot, zoom_factor=1.2)) my_plot.tools.append(PanTool(my_plot, drag_button="right")) my_plot.tools.append(ScatterInspector(my_plot)) lasso_overlay = LassoOverlay(lasso_selection=lasso_selection, component=my_plot, selection_fill_color=0xEF8A62) my_plot.overlays.append(lasso_overlay) my_plot.overlays.append(ScatterInspectorOverlay(my_plot, hover_marker_size=4)) return plot
def _create_plot_component(obj): # Setup the spectrum plot frequencies = linspace(0.0, float(SAMPLING_RATE)/2, num=NUM_SAMPLES/2) obj.spectrum_data = ArrayPlotData(frequency=frequencies) empty_amplitude = zeros(NUM_SAMPLES/2) obj.spectrum_data.set_data('amplitude', empty_amplitude) obj.spectrum_plot = Plot(obj.spectrum_data) spec_renderer = obj.spectrum_plot.plot(("frequency", "amplitude"), name="Spectrum", color="red")[0] obj.spectrum_plot.padding = 50 obj.spectrum_plot.title = "Spectrum" spec_range = list(obj.spectrum_plot.plots.values())[0][0].value_mapper.range spec_range.low = 0.0 spec_range.high = 5.0 obj.spectrum_plot.index_axis.title = 'Frequency (hz)' obj.spectrum_plot.value_axis.title = 'Amplitude' # Time Series plot times = linspace(0.0, float(NUM_SAMPLES)/SAMPLING_RATE, num=NUM_SAMPLES) obj.time_data = ArrayPlotData(time=times) empty_amplitude = zeros(NUM_SAMPLES) obj.time_data.set_data('amplitude', empty_amplitude) obj.time_plot = Plot(obj.time_data) obj.time_plot.plot(("time", "amplitude"), name="Time", color="blue") obj.time_plot.padding = 50 obj.time_plot.title = "Time" obj.time_plot.index_axis.title = 'Time (seconds)' obj.time_plot.value_axis.title = 'Amplitude' time_range = list(obj.time_plot.plots.values())[0][0].value_mapper.range time_range.low = -0.2 time_range.high = 0.2 # Spectrogram plot values = [zeros(NUM_SAMPLES/2) for i in range(SPECTROGRAM_LENGTH)] p = WaterfallRenderer(index = spec_renderer.index, values = values, index_mapper = LinearMapper(range = obj.spectrum_plot.index_mapper.range), value_mapper = LinearMapper(range = DataRange1D(low=0, high=SPECTROGRAM_LENGTH)), y2_mapper = LinearMapper(low_pos=0, high_pos=8, range=DataRange1D(low=0, high=15)), ) spectrogram_plot = p obj.spectrogram_plot = p dummy = Plot() dummy.padding = 50 dummy.index_axis.mapper.range = p.index_mapper.range dummy.index_axis.title = "Frequency (hz)" dummy.add(p) container = HPlotContainer() container.add(obj.spectrum_plot) container.add(obj.time_plot) c2 = VPlotContainer() c2.add(dummy) c2.add(container) return c2
def _create_plot_component(): # Create some data numpts = 1000 x = sort(random(numpts)) y = random(numpts) color = exp(-(x**2 + y**2)) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("color", color) # Create the plot plot = Plot(pd) plot.plot(("index", "value", "color"), type="cmap_scatter", name="my_plot", color_mapper=jet, marker = "square", fill_alpha = 0.5, marker_size = 6, outline_color = "black", border_visible = True, bgcolor = "white") # Tweak some of the plot properties plot.title = "Colormapped Scatter Plot" plot.padding = 50 plot.x_grid.visible = False plot.y_grid.visible = False plot.x_axis.font = "modern 16" plot.y_axis.font = "modern 16" # Right now, some of the tools are a little invasive, and we need the # actual ColomappedScatterPlot object to give to them cmap_renderer = plot.plots["my_plot"][0] # 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) selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35, selection_type="mask") cmap_renderer.overlays.append(selection) # Create the colorbar, handing in the appropriate range and colormap colorbar = create_colorbar(plot.color_mapper) colorbar.plot = cmap_renderer colorbar.padding_top = plot.padding_top colorbar.padding_bottom = plot.padding_bottom # Create a container to position the plot and the colorbar side-by-side container = HPlotContainer(use_backbuffer = True) container.add(plot) container.add(colorbar) container.bgcolor = "lightgray" return container
def _create_plot_component(): # Create some data npts = 100 x = sort(random(npts)) y = random(npts) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("value2", y * 2) # Create the plot plot = Plot(pd) plot.plot(("index", "value"), type="scatter", name="my_plot", marker="circle", index_sort="ascending", color="slategray", marker_size=6, bgcolor="white") plot.plot(("index", "value2"), type="scatter", name="my_plot", marker="circle", index_sort="ascending", color="red", marker_size=6, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot With Selection" plot.line_width = 1 plot.padding = 50 # Right now, some of the tools are a little invasive, and we need the # actual ScatterPlot object to give to them my_plot = plot.plots["my_plot"][0] # Attach some tools to the plot my_plot.tools.append( ScatterInspector(my_plot, selection_mode="toggle", persistent_hover=False)) my_plot.overlays.append( ScatterInspectorOverlay(my_plot, hover_color="transparent", hover_marker_size=10, hover_outline_color="purple", hover_line_width=2, selection_marker_size=8, selection_color="lawngreen")) my_plot.tools.append(PanTool(my_plot)) my_plot.overlays.append(ZoomTool(my_plot, drag_button="right")) return plot
def _create_plot_component(): # Create some data numpts = 1000 x = numpy.arange(0, numpts) y = numpy.random.random(numpts) marker_size = numpy.random.normal(4.0, 4.0, numpts) color = numpy.random.random(numpts) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Because this is a non-standard renderer, we can't call plot.plot, which # sets up the array data sources, mappers and default index/value ranges. # So, its gotta be done manually for now. index_ds = ArrayDataSource(x) value_ds = ArrayDataSource(y) color_ds = ArrayDataSource(color) # Create the plot plot = Plot(pd) plot.index_range.add(index_ds) plot.value_range.add(value_ds) # Create the index and value mappers using the plot data ranges imapper = LinearMapper(range=plot.index_range) vmapper = LinearMapper(range=plot.value_range) # Create the scatter renderer scatter = ColormappedScatterPlot( index=index_ds, value=value_ds, color_data=color_ds, color_mapper=jet(range=DataRange1D(low=0.0, high=1.0)), fill_alpha=0.4, index_mapper = imapper, value_mapper = vmapper, marker='circle', marker_size=marker_size) # Append the renderer to the list of the plot's plots plot.add(scatter) plot.plots['var_size_scatter'] = [scatter] # Tweak some of the plot properties plot.title = "Variable Size and Color Scatter Plot" 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(): # Generate some data for the eye diagram. num_samples = 5000 samples_per_symbol = 24 y = demo_data(num_samples, samples_per_symbol) # Compute the eye diagram array. ybounds = (-0.25, 1.25) grid = grid_count(y, 2 * samples_per_symbol, offset=16, size=(480, 480), bounds=ybounds).T # Convert the array to floating point, and replace 0 with np.nan. # These points will be transparent in the image plot. grid = grid.astype(np.float32) grid[grid == 0] = np.nan #--------------------------------------------------------------------- # The rest of the function creates the chaco image plot. pd = ArrayPlotData() pd.set_data("eyediagram", grid) plot = Plot(pd) img_plot = plot.img_plot("eyediagram", xbounds=(0, 2), ybounds=ybounds, bgcolor=(0, 0, 0), colormap=cool)[0] # Tweak some of the plot properties plot.title = "Eye Diagram" plot.padding = 50 # Axis grids vgrid = PlotGrid(component=plot, mapper=plot.index_mapper, orientation='vertical', line_color='gray', line_style='dot') hgrid = PlotGrid(component=plot, mapper=plot.value_mapper, orientation='horizontal', line_color='gray', line_style='dot') plot.underlays.append(vgrid) plot.underlays.append(hgrid) # Add pan and zoom tools. plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=img_plot, tool_mode="box", always_on=False) img_plot.overlays.append(zoom) return plot
def _plot_default(self): plot = Plot(self.data) plot.plot( ('t', 'y0'), color=colors[0] ) plot.padding=20 plot.padding_left = 40 plot.tools.append(PanTool(plot))#, constrain=True, constrain_direction="y")) #TODO: zoomtool works on both axes, should only affect y plot.tools.append(ZoomTool(plot, tool_mode="range", constrain=True, constrain_direction="y")) return plot
def _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.padding = 0 self.tcm = TransformColorMapper.from_color_map(gray) self.tcm.unit_func = self.unit_map.function self.unit_map.on_trait_change(self.map_changed, 'function') plot.img_plot('image', colormap=self.tcm) return plot
def _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.x_grid = None plot.y_grid = None plot.padding = 0 plot.plot('image_histogram') plot.plot('mapped_histogram', type='filled_line', fill_color='yellow') return plot
def main(): # 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 plot = Plot( pd, bgcolor="none", padding=30, border_visible=True, overlay_border=True, use_backbuffer=False) plot.legend.visible = True plot.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="auto") plot.plot(("index", "y3"), name="j_3", color="auto") plot.tools.append(PanTool(plot)) zoom = ZoomTool(component=plot, tool_mode="box", always_on=False) plot.overlays.append(zoom) # Create the mlab test mesh and get references to various parts of the # VTK pipeline f = mlab.figure(size=(600, 500)) m = mlab.test_mesh() scene = mlab.gcf().scene render_window = scene.render_window renderer = scene.renderer rwi = scene.interactor plot.resizable = "" plot.bounds = [200, 200] plot.padding = 25 plot.bgcolor = "lightgray" plot.outer_position = [30, 30] plot.tools.append(MoveTool(component=plot, drag_button="right")) container = OverlayPlotContainer(bgcolor="transparent", fit_window=True) container.add(plot) # Create the Enable Window window = EnableVTKWindow( rwi, renderer, component=container, #istyle_class = tvtk.InteractorStyleSwitch, #istyle_class = tvtk.InteractorStyle, istyle_class=tvtk.InteractorStyleTrackballCamera, bgcolor="transparent", event_passthrough=True, ) mlab.show() return window, render_window
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 _create_plot_component(): # Create some data npts = 200 x = sort(random(npts)) y = random(npts) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Create the plot plot = Plot(pd) plot.plot(("index", "value"), type="scatter", name="my_plot", marker="circle", index_sort="ascending", color="red", marker_size=4, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot With Rectangular Selection" plot.line_width = 1 plot.padding = 50 # Right now, some of the tools are a little invasive, and we need the # actual ScatterPlot object to give to them my_plot = plot.plots["my_plot"][0] # Attach some tools to the plot rect_selection = RectangularSelection( component=my_plot, selection_datasource=my_plot.index, drag_button="left", metadata_name='selections', ) my_plot.tools.append(rect_selection) my_plot.tools.append(ScatterInspector(my_plot, selection_mode='toggle')) my_plot.active_tool = rect_selection lasso_overlay = LassoOverlay(lasso_selection=rect_selection, component=my_plot) my_plot.overlays.append(lasso_overlay) scatter_overlay = ScatterInspectorOverlay( component=my_plot, selection_color='cornflowerblue', selection_marker_size=int(my_plot.marker_size) + 3, selection_marker='circle') my_plot.overlays.append(scatter_overlay) return plot
def create_plot(): # Create some data numpts = 200 x = sort(random(numpts)) y = random(numpts) color = exp(-(x**2 + y**2)) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("color", color) # Create the plot plot = Plot(pd) plot.plot(("index", "value", "color"), type="cmap_scatter", name="my_plot", color_mapper=jet, marker="square", fill_alpha=0.5, marker_size=6, outline_color="black", border_visible=True, bgcolor="white") # Tweak some of the plot properties plot.title = "Colormapped Scatter Plot" plot.padding = 50 plot.x_grid.visible = False plot.y_grid.visible = False plot.x_axis.font = "modern 16" plot.y_axis.font = "modern 16" # Set colors #plot.title_color = "white" #for axis in plot.x_axis, plot.y_axis: # axis.trait_set(title_color="white", tick_label_color="white") # Right now, some of the tools are a little invasive, and we need the # actual ColomappedScatterPlot object to give to them cmap_renderer = plot.plots["my_plot"][0] # 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) selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35, selection_type="mask") cmap_renderer.overlays.append(selection) plot.tools.append(MoveTool(plot, drag_button="right")) return plot
def create_plot(): # Create some data numpts = 200 x = sort(random(numpts)) y = random(numpts) color = exp(-(x**2 + y**2)) # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) pd.set_data("color", color) # Create the plot plot = Plot(pd) plot.plot(("index", "value", "color"), type="cmap_scatter", name="my_plot", color_mapper=jet, marker = "square", fill_alpha = 0.5, marker_size = 6, outline_color = "black", border_visible = True, bgcolor = "white") # Tweak some of the plot properties plot.title = "Colormapped Scatter Plot" plot.padding = 50 plot.x_grid.visible = False plot.y_grid.visible = False plot.x_axis.font = "modern 16" plot.y_axis.font = "modern 16" # Set colors #plot.title_color = "white" #for axis in plot.x_axis, plot.y_axis: # axis.set(title_color="white", tick_label_color="white") # Right now, some of the tools are a little invasive, and we need the # actual ColomappedScatterPlot object to give to them cmap_renderer = plot.plots["my_plot"][0] # 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) selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35, selection_type="mask") cmap_renderer.overlays.append(selection) plot.tools.append(MoveTool(plot, drag_button="right")) return plot
def _create_plot_component(): # Create some data numpts = 5000 x = sort(np.random.random(numpts)) y = np.random.random(numpts) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("index", x) pd.set_data("value", y) # Generate Random marker and outline colors # The arrays must be RGBA color tuples. Create the appropriate arrays. col_array=np.zeros(len(x),dtype=('f8,f8,f8,f8')) outline_col_array=np.zeros(len(x),dtype=('f8,f8,f8,f8')) colors=[] for i in range(len(x)): colors.append(random.choice(enable.colors.color_table.keys())) for idx, color in enumerate(colors): col_array[idx] = enable.colors.color_table[color] colors=[] for i in range(len(x)): colors.append(random.choice(enable.colors.color_table.keys())) for idx, color in enumerate(colors): outline_col_array[idx] = enable.colors.color_table[color] # Create the plot plot = Plot(pd) plot.plot(("index", "value"), type="scatter", marker="circle", index_sort="ascending", color=col_array, marker_size=3, outline_color = outline_col_array, bgcolor="white") # Tweak some of the plot properties plot.title = "Scatter Plot" 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 _main_plot_default(self): p = Plot(self.plot_data, default_origin='top left') p.padding = 0 self.original_plot = p.img_plot('original_image', colormap=bone, alpha=self.original_alpha, bgcolor=self.background_color_)[0] self.canny_plot = p.img_plot('canny_plot_image', alpha=self.canny_alpha)[0] p.x_axis = None p.y_axis = None self.segments_overlay = SegmentsOverlay(component=self.canny_plot, image_size=self.image.canny_image.shape) p.overlays.append(self.segments_overlay) return p
def _plot_default(self): plot = Plot(self.plot_data) plot.x_axis = None plot.y_axis = None plot.x_grid = None plot.y_grid = None plot.padding = 0 plot.plot(('x', 'image_histogram'), render_style='connectedhold') plot.plot(('x', 'mapped_histogram'), type='filled_line', fill_color='yellow', render_style='connectedhold', name='mapped_histogram') intercept_tool = AttributeDragTool(component=plot, model=self.unit_map, x_attr='intercept') plot.tools.append(intercept_tool) return plot
def _time_plot_default(self): plot = Plot(self.data) line_plot = plot.plot(('t', 'y'))[0] line_plot.active_tool = RangeSelection(line_plot, left_button_selects=True) line_plot.overlays.append(RangeSelectionOverlay(component=line_plot)) self.selection = line_plot.active_tool plot.padding = 20 plot.padding_left = 50 self.selection.on_trait_change(self.handle_selection_change, 'selection') return plot
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.padding = 0 return plot
def _plot_default(self): plot = Plot(self.data) plot.plot(('t', 'y0'), color=colors[0]) plot.padding = 20 plot.padding_left = 40 plot.tools.append( PanTool(plot)) #, constrain=True, constrain_direction="y")) #TODO: zoomtool works on both axes, should only affect y plot.tools.append( ZoomTool(plot, tool_mode="range", constrain=True, constrain_direction="y")) return plot
def _plot_default(self): # Create the plot plot = Plot(self.dataset) plot.plot(("index", "value"), type="scatter", marker='circle', color='blue') # Tweak some of the plot properties plot.title = "Scatter Plot" plot.line_width = 0.5 plot.padding = 50 return plot
def _main_plot_default(self): p = Plot(self.plot_data, default_origin='top left') p.padding = 0 self.original_plot = p.img_plot('original_image', colormap=bone, alpha=self.original_alpha, bgcolor=self.background_color_)[0] self.canny_plot = p.img_plot('canny_plot_image', alpha=self.canny_alpha)[0] p.x_axis = None p.y_axis = None self.segments_overlay = SegmentsOverlay( component=self.canny_plot, image_size=self.image.canny_image.shape) p.overlays.append(self.segments_overlay) return p
def _create_plot_component(): red = util.Color(255, 0, 0, 255) green = util.Color(0, 255, 0, 255) blue = util.Color(0, 0, 255, 255) purple = util.Color(125, 0, 255, 255) white = util.Color(255, 255, 255, 255) black = util.Color(0, 0, 0, 255) clear = util.Color(0, 0, 0, 0) with Timer("Loeading") as arTimer: #glyphs = npg.load_csv("../data/circlepoints.csv", 1, 2, 3, 4) #glyphs = npg.load_hdf("../data/CensusTracts.hdf5", "__data__", "LAT", "LON") glyphs = npg.load_hdf("../data/tweets-subset.hdf", "test", "longitude", "latitude", vc="lang_primary") screen = (800, 600) ivt = util.zoom_fit(screen, glyphs.bounds()) with Timer("Abstract-Render") as arTimer: image = core.render( glyphs, infos.encode(["Arabic", "English", "Turkish", "Russian"]), npg.PointCountCategories(), npg.Spread(2) + categories.HDAlpha( [red, blue, green, purple, black], alphamin=.3, log=True), screen, ivt) # image = core.render(glyphs, # infos.valAt(4,0), # npg.PointCount(), # npg.Spread(1) + numeric.BinarySegment(white, black, 1), # screen, # ivt) # Create a plot data object and give it this data pd = ArrayPlotData() pd.set_data("imagedata", image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata")[0] # Tweak some of the plot properties plot.title = "Abstract Rendering" plot.padding = 50 return plot
def _plot_default(self): # Create a plot data obect and give it this data pd = ArrayPlotData() pd.set_data("imagedata", self.image) # Create the plot plot = Plot(pd) img_plot = plot.img_plot("imagedata") # Tweak some of the plot properties plot.padding = 0 # Attach some tools to the plot plot.tools.append(ClickTool(plot)) return plot