Ejemplo n.º 1
0
    def _plot_series(self, po, pid, omits):
        graph = self.graph
        try:
            ys = [ai.nominal_value for ai in self._unpack_attr(po.name)]
            yerr = [ai.std_dev for ai in self._unpack_attr(po.name)]

            n = [ai.record_id for ai in self.sorted_analyses]

            args = graph.new_series(x=self.xs,
                                    y=ys,
                                    display_index=ArrayDataSource(data=n),
                                    yerror=yerr,
                                    fit=po.fit,
                                    plotid=pid,
                                    type='scatter')
            if len(args) == 2:
                scatter, p = args
            else:
                p, scatter, l = args

            sel = scatter.index.metadata.get('selections', [])
            sel += omits
            scatter.index.metadata['selections'] = list(set(sel))

            if po.use_time_axis:
                p.x_axis.tick_generator = ScalesTickGenerator(
                    scale=CalendarScaleSystem())

            #p.value_scale = po.scale
            self._add_error_bars(scatter, yerr, 'y', 1, visible=po.y_error)
        except (KeyError, ZeroDivisionError), e:
            print 'Series', e
Ejemplo n.º 2
0
    def set_time_xaxis(self, plotid=None):
        if plotid is None:
            plotid = len(self.plots) - 1

        p = self.plots[plotid]
        p.x_axis.tick_generator = ScalesTickGenerator(
            scale=CalendarScaleSystem())
Ejemplo n.º 3
0
    def set_time_xaxis(self, plotid=None):
        from chaco.scales_tick_generator import ScalesTickGenerator
        from chaco.scales.time_scale import CalendarScaleSystem

        if plotid is None:
            plotid = len(self.plots) - 1

        p = self.plots[plotid]

        p.x_axis.tick_generator = ScalesTickGenerator(
            scale=CalendarScaleSystem())
Ejemplo n.º 4
0
    def _plot_series(self, po, pid, xs, ys):
        graph = self.graph
        try:
            scatter, p = graph.new_series(x=xs,
                                          y=ys,
                                          fit=po.fit,
                                          plotid=pid,
                                          type='scatter')
            if po.use_time_axis:
                p.x_axis.tick_generator = ScalesTickGenerator(
                    scale=CalendarScaleSystem())

        except (KeyError, ZeroDivisionError), e:
            print 'Series', e
Ejemplo n.º 5
0
    def _plot_series(self, po, pid, omits):
        graph = self.graph
        try:
            if po.name == 'AnalysisType':
                ys = list(self._unpack_attr(po.name))
                kw = dict(y=ys, colors=ys, type='cmap_scatter', marker_size=4, color_map_name='gist_rainbow')
                yerr = None
                value_format = analysis_type_formatter
                set_ylimits = False
            else:
                value_format = None
                ys = array([ai.nominal_value for ai in self._unpack_attr(po.name)])
                yerr = array([ai.std_dev for ai in self._unpack_attr(po.name)])
                kw = dict(y=ys, yerror=yerr, type='scatter')
                set_ylimits = True

            n = [ai.record_id for ai in self.sorted_analyses]
            args = graph.new_series(x=self.xs,
                                    display_index=ArrayDataSource(data=n),
                                    fit=po.fit,
                                    plotid=pid,
                                    # type='scatter',
                                    add_inspector=False,
                                    **kw)
            if len(args) == 2:
                scatter, p = args
            else:
                p, scatter, l = args

            sel = scatter.index.metadata.get('selections', [])
            sel += omits
            scatter.index.metadata['selections'] = list(set(sel))

            self._add_scatter_inspector(scatter, value_format=value_format)

            if po.use_time_axis:
                p.x_axis.tick_generator = ScalesTickGenerator(scale=CalendarScaleSystem())

            #p.value_scale = po.scale
            end_caps = True
            if po.y_error and yerr is not None:
                self._add_error_bars(scatter, yerr, 'y', 2, end_caps, visible=True)

            if set_ylimits:
                mi, mx = min(ys - 2 * yerr), max(ys + 2 * yerr)
                graph.set_y_limits(min_=mi, max_=mx, pad='0.1', plotid=pid)

        except (KeyError, ZeroDivisionError, AttributeError), e:
            print 'Series', e
Ejemplo n.º 6
0
def _set_scale(axis, system):
    p = curplot()
    if p:
        if axis == 'x':
            log_linear_trait = 'index_scale'
            ticks = p.x_ticks
        else:
            log_linear_trait = 'value_scale'
            ticks = p.y_ticks
        if system == 'time':
            system = CalendarScaleSystem()
        if isinstance(system, six.string_types):
            setattr(p, log_linear_trait, system)
        else:
            if system is None:
                system = dict(linear=p.linear_scale, log=p.log_scale).get(
                    p.get(log_linear_trait), p.linear_scale)
            ticks.scale = system
        p.request_redraw()
Ejemplo n.º 7
0
def test_calendar_scale_system_01():
    css = CalendarScaleSystem()
    ticks = css.ticks(0,10)
    assert len(ticks) == 11
    assert (np.array(ticks) == np.linspace(0,10,11)).all()
Ejemplo n.º 8
0
def test_calendar_scale_system_01():
    css = CalendarScaleSystem()
    ticks = css.ticks(0, 10)
    assert len(ticks) == 11
    assert (np.array(ticks) == np.linspace(0, 10, 11)).all()
Ejemplo n.º 9
0
 def test_calendar_scale_system_01(self):
     css = CalendarScaleSystem()
     ticks = css.ticks(0, 10)
     self.assertEqual(len(ticks), 11)
     nptest.assert_array_equal(np.array(ticks), np.linspace(0, 10, 11))
Ejemplo n.º 10
0
    def _plot_series(self, po, pid, omits):
        graph = self.graph
        try:
            if po.name == 'AnalysisType':
                from pychron.pipeline.plot.plotter.ticks import analysis_type_formatter

                ys = list(self._unpack_attr(po.name))
                kw = dict(y=ys,
                          colors=ys,
                          type='cmap_scatter',
                          fit='',
                          color_map_name='gist_rainbow')
                yerr = None
                value_format = analysis_type_formatter
                set_ylimits = False

            else:
                set_ylimits = True
                value_format = None
                ys = array(
                    [ai.nominal_value for ai in self._unpack_attr(po.name)])
                yerr = array([ai.std_dev for ai in self._unpack_attr(po.name)])
                kw = dict(y=ys,
                          yerror=yerr,
                          type='scatter',
                          fit='{}_{}'.format(po.fit, po.error_type),
                          filter_outliers_dict=po.filter_outliers_dict)

            # print ys
            n = [ai.record_id for ai in self.sorted_analyses]
            args = graph.new_series(x=self.xs,
                                    display_index=ArrayDataSource(data=n),
                                    plotid=pid,
                                    add_inspector=False,
                                    marker=po.marker,
                                    marker_size=po.marker_size,
                                    **kw)
            if len(args) == 2:
                scatter, p = args
            else:
                p, scatter, l = args

            sel = scatter.index.metadata.get('selections', [])
            sel += omits
            scatter.index.metadata['selections'] = list(set(sel))

            def af(i, x, y, analysis):
                return ('Run Date: {}'.format(
                    analysis.rundate.strftime('%m-%d-%Y %H:%M')),
                        'Rel. Time: {:0.4f}'.format(x))

            self._add_scatter_inspector(scatter,
                                        additional_info=af,
                                        value_format=value_format)

            if po.use_time_axis:
                p.x_axis.tick_generator = ScalesTickGenerator(
                    scale=CalendarScaleSystem())

            # p.value_scale = po.scale
            end_caps = True
            if po.y_error and yerr is not None:
                self._add_error_bars(scatter,
                                     yerr,
                                     'y',
                                     2,
                                     end_caps,
                                     visible=True)

            if set_ylimits:
                mi, mx = min(ys - 2 * yerr), max(ys + 2 * yerr)
                graph.set_y_limits(min_=mi, max_=mx, pad='0.1', plotid=pid)

        except (KeyError, ZeroDivisionError, AttributeError), e:
            import traceback

            traceback.print_exc()
            print 'Series', e
Ejemplo n.º 11
0
 def new_plot(self, **kw):
     p = super(ContextGraph, self).new_plot(**kw)
     p.x_axis.tick_generator = ScalesTickGenerator(
         scale=CalendarScaleSystem())
     return p