Beispiel #1
0
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 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
Beispiel #3
0
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
Beispiel #4
0
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
Beispiel #5
0
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
Beispiel #6
0
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 _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
Beispiel #8
0
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
Beispiel #9
0
    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
Beispiel #10
0
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():

    # 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
Beispiel #13
0
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_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
Beispiel #15
0
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)

    # 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")

    # 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 _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
Beispiel #17
0
def _create_plot_component():

    # Create some data
    npts = 2000
    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 Lasso 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
    lasso_selection = LassoSelection(component=my_plot,
                                     selection_datasource=my_plot.index,
                                     drag_button="left")
                                     #drag_button="right")
    my_plot.active_tool = lasso_selection
    my_plot.tools.append(ScatterInspector(my_plot))
    lasso_overlay = LassoOverlay(lasso_selection=lasso_selection,
                                 component=my_plot)
    my_plot.overlays.append(lasso_overlay)

    # Uncomment this if you would like to see incremental updates:
    #lasso_selection.incremental_select = True

    return plot
Beispiel #18
0
def _create_plot_component():

    # Create some data
    npts = 2000
    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 Lasso 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
    lasso_selection = LassoSelection(component=my_plot,
                                     selection_datasource=my_plot.index,
                                     drag_button="left")
    #drag_button="right")
    my_plot.active_tool = lasso_selection
    my_plot.tools.append(ScatterInspector(my_plot))
    lasso_overlay = LassoOverlay(lasso_selection=lasso_selection,
                                 component=my_plot)
    my_plot.overlays.append(lasso_overlay)

    # Uncomment this if you would like to see incremental updates:
    #lasso_selection.incremental_select = True

    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 _create_plot_component():

    # Create some data
    numpts = 300
    x = sort(random(numpts))
    y = random(numpts)

    # create a custom marker
    marker = make_custom_marker()

    # 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="custom",
              custom_symbol=marker,
              index_sort="ascending",
              color="orange",
              marker_size=3,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = "Scatter plot with custom markers"
    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
Beispiel #21
0
def _create_plot_component():

    # Create some data
    numpts = 1000
    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",
              name="my_plot",
              marker="square",
              index_sort="ascending",
              color="lightblue",
              outline_color="none",
              marker_size=3,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = "Click to add points, press Enter to finalize selection"
    plot.padding = 50
    plot.line_width = 1

    # Attach some tools to the plot
    pan = PanTool(plot, drag_button="right", constrain_key="shift")
    plot.tools.append(pan)
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
    plot.overlays.append(MyLineDrawer(plot))
    return plot
Beispiel #22
0
def _create_plot_component():

    # Create some data
    numpts = 1000
    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",
              name="my_plot",
              marker="square",
              index_sort="ascending",
              color="lightblue",
              outline_color="none",
              marker_size=3,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = "Click to add points, press Enter to finalize selection"
    plot.padding = 50
    plot.line_width = 1

    # Attach some tools to the plot
    pan = PanTool(plot, drag_button="right", constrain_key="shift")
    plot.tools.append(pan)
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
    plot.overlays.append(MyLineDrawer(plot))
    return plot
Beispiel #23
0
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
Beispiel #24
0
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