def _theta_plot_default(self): theta = self.theta nclasses = theta.shape[0] # create a plot data object and give it this data plot_data = ArrayPlotData() plot_data.set_data('classes', list(range(nclasses))) # create the plot plot = Plot(plot_data) # --- plot theta samples if self.theta_samples is not None: self._plot_samples(plot, plot_data) # --- plot values of theta plots = self._plot_theta_values(plot, plot_data) # --- adjust plot appearance plot.aspect_ratio = 1.6 if is_display_small() else 1.7 # adjust axis bounds y_high = theta.max() if self.theta_samples is not None: y_high = max(y_high, self.theta_samples.max()) plot.range2d = DataRange2D(low=(-0.2, 0.0), high=(nclasses - 1 + 0.2, y_high * 1.1)) # create new horizontal axis label_axis = self._create_increment_one_axis(plot, 0., nclasses, 'bottom') label_axis.title = 'True classes' self._add_index_axis(plot, label_axis) # label vertical axis plot.value_axis.title = 'Probability' # add legend legend = Legend(component=plot, plots=plots, align="ur", border_padding=10) legend.tools.append(LegendTool(legend, drag_button="left")) legend.padding_right = -100 plot.overlays.append(legend) container = VPlotContainer(width=plot.width + 100, halign='left') plot.padding_bottom = 50 plot.padding_top = 10 plot.padding_left = 0 container.add(plot) container.bgcolor = 0xFFFFFF self.decorate_plot(container, theta) return container
def _theta_plot_default(self): theta = self.theta nclasses = theta.shape[0] # create a plot data object and give it this data plot_data = ArrayPlotData() plot_data.set_data('classes', range(nclasses)) # create the plot plot = Plot(plot_data) # --- plot theta samples if self.theta_samples is not None: self._plot_samples(plot, plot_data) # --- plot values of theta plots = self._plot_theta_values(plot, plot_data) # --- adjust plot appearance plot.aspect_ratio = 1.6 if is_display_small() else 1.7 # adjust axis bounds y_high = theta.max() if self.theta_samples is not None: y_high = max(y_high, self.theta_samples.max()) plot.range2d = DataRange2D( low = (-0.2, 0.0), high = (nclasses-1+0.2, y_high*1.1) ) # create new horizontal axis label_axis = self._create_increment_one_axis( plot, 0., nclasses, 'bottom') label_axis.title = 'True classes' self._add_index_axis(plot, label_axis) # label vertical axis plot.value_axis.title = 'Probability' # add legend legend = Legend(component=plot, plots=plots, align="ur", border_padding=10) legend.tools.append(LegendTool(legend, drag_button="left")) legend.padding_right = -100 plot.overlays.append(legend) container = VPlotContainer(width=plot.width + 100, halign='left') plot.padding_bottom = 50 plot.padding_top = 10 plot.padding_left = 0 container.add(plot) container.bgcolor = 0xFFFFFF self.decorate_plot(container, theta) return container
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
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