Exemplo n.º 1
0
    def _create_increment_one_axis(self, plot, start, number, orientation,
                                   ticks=None):
        """Create axis with ticks at a distance of one units.

        Parameters
        ----------
        plot : Plot
            plot where the axis will be attached
        start : float
            position of first tick
        number : int
            number of ticks
        orientation: ['top', 'bottom', 'left', 'right']
            position of axis on the plot
        ticks : list of strings
            string to be displayed for each tick
        """

        ids = start + np.arange(0, number)
        if ticks is None:
            ticks = [str(idx) for idx in np.arange(0, number)]

        axis = LabelAxis(
            plot,
            orientation = orientation,
            positions = ids,
            labels = ticks,
            label_rotation = 0
        )

        # use a FixedScale tick generator with a resolution of 1
        axis.tick_generator = ScalesTickGenerator(scale=FixedScale(1.))

        return axis
Exemplo n.º 2
0
 def _create_probability_axis(self, plot):
     """Create plot axis for probability values."""
     prob_axis = LabelAxis(plot,
                           orientation='left',
                           positions=[0.5, 0.5 + np.sqrt(0.25) / 2., 1.0],
                           labels=['0', '0.25', '1'])
     prob_axis.tick_generator = ScalesTickGenerator(scale=FixedScale(0.001))
     return prob_axis
Exemplo n.º 3
0
 def _create_probability_axis(self, plot):
     """Create plot axis for probability values."""
     prob_axis = LabelAxis(
         plot,
         orientation='left',
         positions=[0.5, 0.5 + np.sqrt(0.25) / 2., 1.0],
         labels=['0', '0.25', '1']
     )
     prob_axis.tick_generator = ScalesTickGenerator(scale=FixedScale(0.001))
     return prob_axis
Exemplo n.º 4
0
    def _create_increment_one_axis(self,
                                   plot,
                                   start,
                                   number,
                                   orientation,
                                   ticks=None):
        """Create axis with ticks at a distance of one units.

        Parameters
        ----------
        plot : Plot
            plot where the axis will be attached
        start : float
            position of first tick
        number : int
            number of ticks
        orientation: ['top', 'bottom', 'left', 'right']
            position of axis on the plot
        ticks : list of strings
            string to be displayed for each tick
        """

        ids = start + np.arange(0, number)
        if ticks is None:
            ticks = [str(idx) for idx in np.arange(0, number)]

        axis = LabelAxis(plot,
                         orientation=orientation,
                         positions=ids,
                         labels=ticks,
                         label_rotation=0)

        # use a FixedScale tick generator with a resolution of 1
        axis.tick_generator = ScalesTickGenerator(scale=FixedScale(1.))

        return axis
Exemplo n.º 5
0
    def _theta_plot_default(self):
        """Create plot of theta parameters."""

        # We plot both the thetas and the samples from the posterior; if the
        # latter are not defined, the corresponding ArrayPlotData names
        # should be set to an empty list, so that they are not displayed
        theta = self.model.theta
        theta_len = theta.shape[0]

        # create the plot data
        if not self.theta_plot_data:
            self.theta_plot_data = ArrayPlotData()
            self._update_plot_data()

        # create the plot
        theta_plot = Plot(self.theta_plot_data)

        for idx in range(theta_len):
            # candle plot summarizing samples over the posterior
            theta_plot.candle_plot((_w_idx('index', idx),
                                    _w_idx('min', idx),
                                    _w_idx('barmin', idx),
                                    _w_idx('avg', idx),
                                    _w_idx('barmax', idx),
                                    _w_idx('max', idx)),
                                    color = get_annotator_color(idx),
                                    bar_line_color = "black",
                                    stem_color = "blue",
                                    center_color = "red",
                                    center_width = 2)

            # plot of raw samples
            theta_plot.plot((_w_idx('ysamples', idx),
                             _w_idx('xsamples', idx)),
                            type='scatter',
                            color='black',
                            marker='dot',
                            line_width=0.5,
                            marker_size=1)

            # plot current parameters
            theta_plot.plot((_w_idx('y', idx), _w_idx('x', idx)),
                            type='scatter',
                            color=get_annotator_color(idx),
                            marker='plus',
                            marker_size=8,
                            line_width=2)

        # adjust axis bounds
        theta_plot.range2d = self._compute_range2d()

        # remove horizontal grid and axis
        theta_plot.underlays = [theta_plot.x_grid, theta_plot.y_axis]

        # create new horizontal axis
        label_list = [str(i) for i in range(theta_len)]

        label_axis = LabelAxis(
            theta_plot,
            orientation = 'bottom',
            positions = range(1, theta_len+1),
            labels = label_list,
            label_rotation = 0
        )
        # use a FixedScale tick generator with a resolution of 1
        label_axis.tick_generator = ScalesTickGenerator(scale=FixedScale(1.))

        theta_plot.index_axis = label_axis
        theta_plot.underlays.append(label_axis)
        theta_plot.padding = 25
        theta_plot.padding_left = 40
        theta_plot.aspect_ratio = 1.0

        container = VPlotContainer()
        container.add(theta_plot)
        container.bgcolor = 0xFFFFFF

        self.decorate_plot(container, theta)
        self._set_title(theta_plot)

        return container
Exemplo n.º 6
0
    def _theta_plot_default(self):
        """Create plot of theta parameters."""

        # We plot both the thetas and the samples from the posterior; if the
        # latter are not defined, the corresponding ArrayPlotData names
        # should be set to an empty list, so that they are not displayed
        theta = self.model.theta
        theta_len = theta.shape[0]

        # create the plot data
        if not self.theta_plot_data:
            self.theta_plot_data = ArrayPlotData()
            self._update_plot_data()

        # create the plot
        theta_plot = Plot(self.theta_plot_data)

        for idx in range(theta_len):
            # candle plot summarizing samples over the posterior
            theta_plot.candle_plot((_w_idx('index', idx),
                                    _w_idx('min', idx),
                                    _w_idx('barmin', idx),
                                    _w_idx('avg', idx),
                                    _w_idx('barmax', idx),
                                    _w_idx('max', idx)),
                                    color = get_annotator_color(idx),
                                    bar_line_color = "black",
                                    stem_color = "blue",
                                    center_color = "red",
                                    center_width = 2)

            # plot of raw samples
            theta_plot.plot((_w_idx('ysamples', idx),
                             _w_idx('xsamples', idx)),
                            type='scatter',
                            color='black',
                            marker='dot',
                            line_width=0.5,
                            marker_size=1)

            # plot current parameters
            theta_plot.plot((_w_idx('y', idx), _w_idx('x', idx)),
                            type='scatter',
                            color=get_annotator_color(idx),
                            marker='plus',
                            marker_size=8,
                            line_width=2)

        # adjust axis bounds
        theta_plot.range2d = self._compute_range2d()

        # remove horizontal grid and axis
        theta_plot.underlays = [theta_plot.x_grid, theta_plot.y_axis]

        # create new horizontal axis
        label_list = [str(i) for i in range(theta_len)]

        label_axis = LabelAxis(
            theta_plot,
            orientation = 'bottom',
            positions = list(range(1, theta_len+1)),
            labels = label_list,
            label_rotation = 0
        )
        # use a FixedScale tick generator with a resolution of 1
        label_axis.tick_generator = ScalesTickGenerator(scale=FixedScale(1.))

        theta_plot.index_axis = label_axis
        theta_plot.underlays.append(label_axis)
        theta_plot.padding = 25
        theta_plot.padding_left = 40
        theta_plot.aspect_ratio = 1.0

        container = VPlotContainer()
        container.add(theta_plot)
        container.bgcolor = 0xFFFFFF

        self.decorate_plot(container, theta)
        self._set_title(theta_plot)

        return container