コード例 #1
0
ファイル: degasser.py プロジェクト: ael-noblegas/pychron
    def _setup_graph(self):
        self.plot_container = HPlotContainer()
        g = self.stream_graph
        g.clear()
        g.new_plot(padding_left=70, padding_right=10)
        g.new_series(plotid=0)
        g.set_y_title('Lumens', plotid=0)
        g.new_plot(padding_left=70, padding_right=10)
        g.new_series(plotid=1)
        g.set_y_title('Error', plotid=1)
        g.new_plot(padding_left=70, padding_right=10)
        g.new_series(plotid=2)
        g.set_y_title('Output', plotid=2)

        g = self.img_graph
        g.clear()
        imgplot = g.new_plot(padding_right=10)
        imgplot.aspect_ratio = 1.0
        imgplot.x_axis.visible = False
        imgplot.y_axis.visible = False
        imgplot.x_grid.visible = False
        imgplot.y_grid.visible = False

        imgplot.data.set_data('imagedata', zeros((150, 150, 3), dtype=uint8))
        imgplot.img_plot('imagedata', origin='top left')

        self.plot_container.add(self.stream_graph.plotcontainer)
        self.plot_container.add(self.img_graph.plotcontainer)
コード例 #2
0
    def _matrix_plot_container_default(self):
        matrix = np.nan_to_num(self.matrix)
        width = matrix.shape[0]

        # create a plot data object and give it this data
        plot_data = ArrayPlotData()
        plot_data.set_data("values", matrix)

        # create the plot
        plot = Plot(plot_data, origin=self.origin)

        img_plot = plot.img_plot("values",
                                 interpolation='nearest',
                                 xbounds=(0, width),
                                 ybounds=(0, width),
                                 colormap=self._create_colormap())[0]

        #### fix axes
        self._remove_grid_and_axes(plot)

        axis = self._create_increment_one_axis(plot, 0.5, width, 'bottom')
        self._add_value_axis(plot, axis)

        axis = self._create_increment_one_axis(
            plot,
            0.5,
            width,
            'left',
            ticks=[str(i) for i in range(width - 1, -1, -1)])
        self._add_index_axis(plot, axis)

        #### tweak plot attributes
        self._set_title(plot)
        plot.aspect_ratio = 1.
        # padding [left, right, up, down]
        plot.padding = [0, 0, 25, 25]

        # create the colorbar, handing in the appropriate range and colormap
        colormap = img_plot.color_mapper
        colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
                            color_mapper=colormap,
                            plot=img_plot,
                            orientation='v',
                            resizable='v',
                            width=20,
                            padding=[0, 20, 0, 0])
        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 = 0xFFFFFF

        self.decorate_plot(container, self.matrix)
        return container
コード例 #3
0
    def _plot_default(self):
        distr_len = len(self.data)

        # PolygonPlot holding the circles of the Hinton diagram
        polyplot = Plot(self.plot_data)
        for idx in range(distr_len):
            p = polyplot.plot(('x%d' % idx, 'y%d' % idx),
                              type="polygon",
                              face_color=get_class_color(idx),
                              edge_color='black')

        self._set_title(polyplot)
        self._remove_grid_and_axes(polyplot)

        # create x axis for labels
        axis = self._create_increment_one_axis(polyplot, 1., distr_len,
                                               'bottom')
        self._add_index_axis(polyplot, axis)

        # create y axis for probability density
        #prob_axis = self._create_probability_axis(polyplot)
        #polyplot.value_axis = prob_axis
        #polyplot.underlays.append(prob_axis)

        # tweak some of the plot properties
        range2d = DataRange2D(low=(0.5, 0.), high=(distr_len + 0.5, 1.))
        polyplot.range2d = range2d
        polyplot.aspect_ratio = ((range2d.x_range.high - range2d.x_range.low) /
                                 (range2d.y_range.high - range2d.y_range.low))

        polyplot.border_visible = False
        polyplot.padding = [0, 0, 25, 25]

        # create a container to position the plot and the colorbar side-by-side
        container = HPlotContainer(use_backbuffer=True, valign='center')
        container.add(polyplot)
        container.bgcolor = 0xFFFFFF  # light gray: 0xEEEEEE

        self.decorate_plot(container, self.data)
        return container
コード例 #4
0
    def make_component(self, padding):
        cg = ContourGraph()

        cg.new_plot(title='Beam Space',
                    xtitle='X mm',
                    ytitle='Y mm',
                    aspect_ratio=1)

        g = Graph()
        g.new_plot(
            title='Motor Space',
            xtitle='X mm',
            ytitle='Power',
        )
        g.new_series()

        self.graph = g
        self.contour_graph = cg
        c = HPlotContainer()
        c.add(g.plotcontainer)
        c.add(cg.plotcontainer)

        return c
コード例 #5
0
 def _container_factory(self):
     pc = HPlotContainer(padding=[5, 5, 5, 20])
     return pc
コード例 #6
0
 def _container_default(self):
     hp = HPlotContainer(padding=0, spacing=0)
     return hp
コード例 #7
0
    def _plot_container_default(self):
        data = self.posterior
        nannotations, nclasses = data.shape

        # create a plot data object
        plot_data = ArrayPlotData()
        plot_data.set_data("values", data)

        # create the plot
        plot = Plot(plot_data, origin=self.origin)

        img_plot = plot.img_plot("values",
                                 interpolation='nearest',
                                 xbounds=(0, nclasses),
                                 ybounds=(0, nannotations),
                                 colormap=self._create_colormap())[0]
        ndisp = 55
        img_plot.y_mapper.range.high = ndisp
        img_plot.y_mapper.domain_limits = ((0, nannotations))

        self._set_title(plot)
        plot.padding_top = 80

        # create x axis for labels
        label_axis = self._create_increment_one_axis(plot, 0.5, nclasses,
                                                     'top')
        label_axis.title = 'classes'
        self._add_index_axis(plot, label_axis)

        plot.y_axis.title = 'items'

        # tweak plot aspect
        goal_aspect_ratio = 2.0
        plot_width = (goal_aspect_ratio * self.plot_height * nclasses / ndisp)
        self.plot_width = min(max(plot_width, 200), 400)
        plot.aspect_ratio = self.plot_width / self.plot_height

        # add colorbar
        colormap = img_plot.color_mapper
        colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
                            color_mapper=colormap,
                            plot=img_plot,
                            orientation='v',
                            resizable='',
                            width=15,
                            height=250)
        colorbar.padding_top = plot.padding_top
        colorbar.padding_bottom = int(self.plot_height - colorbar.height -
                                      plot.padding_top)
        colorbar.padding_left = 0
        colorbar.padding_right = 30

        # 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 = 0xFFFFFF  # light gray: 0xEEEEEE

        # add pan tools
        img_plot.tools.append(
            PanTool(img_plot,
                    constrain=True,
                    constrain_direction="y",
                    speed=7.))

        self.decorate_plot(container, self.posterior)
        self.plot_posterior = plot
        return container
コード例 #8
0
    def setup_graph(self, an):

        container = HPlotContainer()

        container_dict = {'spacing': 5, 'stack_order': 'top_to_bottom'}
        sg = StackedGraph(container_dict=container_dict)
        sg.plotcontainer.spacing = 5
        sg.plotcontainer.stack_order = 'top_to_bottom'

        isos = an.sorted_values(reverse=False)
        add_sniff = True

        sisos = [iso for iso in isos if iso.sniff.offset_xs.shape[0]]
        for i, iso in enumerate(sisos):
            sniff = iso.sniff
            sg.new_plot(ytitle=iso.name,
                        xtitle='Time (s)',
                        title='Equilibration')
            sg.new_series(sniff.offset_xs,
                          sniff.ys,
                          marker='circle',
                          type='scatter')
            sg.set_y_limits(pad='0.1', plotid=i)
            sg.set_x_limits(min_=0, max_=max(sniff.offset_xs) * 1.05, plotid=i)

        bg = StackedRegressionGraph(container_dict=container_dict)
        add_baseline = True

        ig = StackedRegressionGraph(container_dict=container_dict)

        iisos = [iso for iso in isos if iso.offset_xs.shape[0]]
        baselines = []
        for i, iso in enumerate(iisos):
            if iso.baseline.offset_xs.shape[0]:
                baselines.append(iso.baseline)
            ig.new_plot(ytitle='{}({})'.format(iso.name, iso.detector),
                        xtitle='Time (s)',
                        title='Isotope')
            ig.new_series(iso.offset_xs,
                          iso.ys,
                          display_filter_bounds=True,
                          filter_outliers_dict=iso.filter_outliers_dict,
                          color='blue',
                          type='scatter',
                          fit=iso.efit)
            ig.set_regressor(iso.regressor, i)
            ig.set_y_limits(pad='0.1', plotid=i)
            ig.set_x_limits(min_=0, max_=max(iso.offset_xs) * 1.05, plotid=i)

        ig.refresh()

        # bisos = [iso for iso in isos if iso.baseline.offset_xs.shape[0]]
        # plotted_baselines = []
        # for i, iso in enumerate(bisos):
        # baseline = iso.baseline
        # if baseline.detector in plotted_baselines:
        #     continue
        # plotted_baselines.append(baseline.detector)

        # for iso in bisos:
        for i, baseline in enumerate(baselines):

            bg.new_plot(ytitle=baseline.detector,
                        xtitle='Time (s)',
                        title='Baseline')
            bg.new_series(baseline.offset_xs,
                          baseline.ys,
                          filter_outliers_dict=baseline.filter_outliers_dict,
                          display_filter_bounds=True,
                          color='red',
                          type='scatter',
                          fit=baseline.efit)
            bg.set_regressor(baseline.regressor, i)
            bg.set_y_limits(pad='0.1', plotid=i)
            bg.set_x_limits(pad='0.025', plotid=i)

        bg.refresh()

        container.add(sg.plotcontainer)
        container.add(ig.plotcontainer)
        container.add(bg.plotcontainer)

        self.container = container