def plotHistogram(self, image, plot=None): if plot == None: pd = ArrayPlotData(y=np.array([0]), x=np.array([0])) plot = Plot(pd, padding=(70, 10, 0, 0)) plot.plot(('x', 'y'), name='Histogram', type='bar', bar_width=5.0, color='auto') #plot.title = 'Histogram' plot.line_color = 'black' plot.bgcolor = "white" plot.fixed_preferred_size = (100, 30) add_default_grids(plot) plot.value_axis.title = "Histogram" self._appendHistogramTools(plot) ''' plot.overlays.append(PlotAxis(plot, orientation='left')) plot.overlays.append(PlotAxis(plot, orientation='bottom')) ''' else: data = np.histogram(image.data, bins=10000) index = np.delete(data[1], data[1].size-1) values = data[0] plot.index_range.low= np.min(index) plot.index_range.high = np.max(index) plot.value_range.low = 0 plot.value_range.high = np.max(values) plot.data.set_data('x', index) plot.data.set_data('y', values) plot.request_redraw() return plot
def plotHistogram(self, image, plot=None): '''Plots a histogram. | image -- Image object | plot -- plot instance to be updated | if None, a plot instance will be created Returns the plot instance. ''' if plot == None: pd = ArrayPlotData(y=np.array([0]), x=np.array([0])) plot = Plot(pd, padding=(70, 10, 0, 0)) plot.plot(('x', 'y'), name='Histogram', type='bar', bar_width=1.0) plot.line_color = 'black' plot.bgcolor = "white" plot.fixed_preferred_size = (100, 30) add_default_grids(plot) plot.value_range.low = 'auto' plot.value_range.high = 'auto' plot.index_range.low = 'auto' plot.index_range.high = 'auto' plot.value_axis.title = "Histogram" self.appendHistogramTools(plot) else: data = np.histogram(image.data, bins=10000) index = np.delete(data[1], data[1].size-1) values = data[0] self.setData(values, index, plot) plot.invalidate_and_redraw() return plot