Пример #1
0
 def test_orientation(self):
     dv = DataView()
     x_mapper_start = dv.x_mapper
     y_mapper_start = dv.y_mapper
     dv.orientation = "v"
     self.assert_(dv.x_mapper is y_mapper_start)
     self.assert_(dv.y_mapper is x_mapper_start)
Пример #2
0
def _create_plot_component():

    container = DataView()

    xds = FunctionDataSource(func = xfunc)
    yds = FunctionDataSource(func = yfunc)

    xmapper = container.x_mapper
    ymapper = container.y_mapper

    xds.data_range = xmapper.range
    yds.data_range = xmapper.range

    xmapper.range.set_bounds(-5, 10)
    ymapper.range.set_bounds(-1, 1.2)

    plot = ScatterPlot(index = xds, value = yds, index_mapper = xmapper,
                       value_mapper = ymapper,
                       color = "green",
                       marker = "circle",
                       marker_size = 3,
                       line_width = 0)

    plot2 = LinePlot(index = xds, value = yds, index_mapper = xmapper,
                    value_mapper = ymapper,
                    color = "lightgray")

    container.add(plot2, plot)
    plot.tools.append(PanTool(plot, constrain_direction="x", constrain=True))
    plot.tools.append(ZoomTool(plot, axis="index", tool_mode="range"))

    return container
Пример #3
0
def _create_plot_component():
    x = linspace(-5, 10, 500)
    y = sin(x)
    y2 = 0.5 * cos(2*x)

    view = DataView(border_visible = True)
    scatter = ScatterPlot(index = ArrayDataSource(x),
                          value = ArrayDataSource(y),
                          marker = "square",
                          color = "red",
                          outline_color = "transparent",
                          index_mapper = LinearMapper(range=view.index_range),
                          value_mapper = LinearMapper(range=view.value_range))

    line = LinePlot(index = scatter.index,
                    value = ArrayDataSource(y2),
                    color = "blue",
                    index_mapper = LinearMapper(range=view.index_range),
                    value_mapper = LinearMapper(range=view.value_range))

    # Add the plot's index and value datasources to the dataview's
    # ranges so that it can auto-scale and fit appropriately
    view.index_range.sources.append(scatter.index)
    view.value_range.sources.append(scatter.value)
    view.value_range.sources.append(line.value)

    # Add the renderers to the dataview.  The z-order is determined
    # by the order in which renderers are added.
    view.add(scatter)
    view.add(line)
    view.tools.append(PanTool(view))
    view.overlays.append(ZoomTool(view))

    return view
Пример #4
0
    def test_range2d_changed(self):
        dv = DataView()
        ds = GridDataSource()
        dv.range2d.add(ds)
        old_range = dv.range2d
        r = DataRange2D()

        self.assert_(dv.range2d.sources==[ds])
        dv.range2d = r
        self.assert_(dv.range2d.sources==[ds])
        self.assert_(old_range.sources==[])
        self.assert_(dv.range2d.x_range is dv.index_mapper.range)
        self.assert_(dv.range2d.y_range is dv.value_mapper.range)
Пример #5
0
 def _create_TracePlot_component(self):
     plot = DataView(border_visible=True)
     line = LinePlot(value=ArrayDataSource(self.Trace),
                     index=ArrayDataSource(numpy.arange(len(self.Trace))),
                     color='blue',
                     index_mapper=LinearMapper(range=plot.index_range),
                     value_mapper=LinearMapper(range=plot.value_range))
     plot.index_range.sources.append(line.index)
     plot.value_range.sources.append(line.value)
     plot.add(line)
     plot.index_axis.title = 'index'
     plot.value_axis.title = 'Fluorescence [ counts / s ]'
     plot.tools.append(PanTool(plot))
     plot.overlays.append(ZoomTool(plot))
     self.TraceLine = line
     return plot
Пример #6
0
 def _create_HistPlot_component(self):
     plot = DataView(border_visible=True)
     line = LinePlot(
         index=ArrayDataSource(self.HistogramBins),
         value=ArrayDataSource(self.HistogramN),
         color='blue',
         #fill_color='blue',
         index_mapper=LinearMapper(range=plot.index_range),
         value_mapper=LinearMapper(range=plot.value_range))
     plot.index_range.sources.append(line.index)
     plot.value_range.sources.append(line.value)
     plot.add(line)
     plot.index_axis.title = 'Fluorescence counts'
     plot.value_axis.title = 'number of occurences'
     plot.tools.append(PanTool(plot))
     plot.overlays.append(ZoomTool(plot))
     self.HistLine = line
     return plot
Пример #7
0
    def _create_window(self):

        x = linspace(-5, 10, 500)

        y = 0.25 * cos(x)
        y2 = 0.5 * sin(2 * x)

        view = DataView(border_visible=True)

        x_ds = ArrayDataSource(x)
        y_ds = ArrayDataSource(y, sort_order="none")

        lineRed = FilledLinePlot(
            index=x_ds,
            value=y_ds,
            index_mapper=LinearMapper(range=view.index_range),
            value_mapper=LinearMapper(range=view.value_range),
            edge_color="red",
            face_color="paleturquoise",
            bgcolor="white",
            border_visible=True,
        )

        #        lineRed = LinePlot(index = ArrayDataSource(x),
        #                              value = ArrayDataSource(y),
        #                              marker = "square",
        #                              color = "red",
        #                              outline_color = "transparent",
        #                              index_mapper = LinearMapper(range=view.index_range),
        #                              value_mapper = LinearMapper(range=view.value_range))

        lineBlue = LinePlot(
            index=lineRed.index,
            value=ArrayDataSource(y2),
            color="blue",
            index_mapper=LinearMapper(range=view.index_range),
            value_mapper=LinearMapper(range=view.value_range),
        )

        vertical_line = LinePlot(
            index=ArrayDataSource(array([2.5, 2.5], dtype=float)),
            value=ArrayDataSource(array([-0.4, 0.4], dtype=float)),
            color="green",
            index_mapper=LinearMapper(range=view.index_range),
            value_mapper=LinearMapper(range=view.value_range),
        )

        # Add the plot's index and value datasources to the dataview's
        # ranges so that it can auto-scale and fit appropriately
        view.index_range.sources.append(vertical_line.index)
        view.value_range.sources.append(vertical_line.value)
        view.index_range.sources.append(lineRed.index)
        view.value_range.sources.append(lineRed.value)
        view.value_range.sources.append(lineBlue.value)

        # Add the renderers to the dataview.  The z-order is determined
        # by the order in which renderers are added.
        view.add(lineRed)
        view.add(lineBlue)
        view.add(vertical_line)

        view.tools.append(PanTool(view))
        view.overlays.append(ZoomTool(view))

        return Window(self, -1, component=view)