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
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
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
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
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