From c94c860494e16df46efa75027960eeac5340f183 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 12 Oct 2016 14:18:12 +0100 Subject: [PATCH 1/3] Fixed inverted axes on bokeh histogram --- holoviews/plotting/bokeh/chart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holoviews/plotting/bokeh/chart.py b/holoviews/plotting/bokeh/chart.py index 741758ed5c..4acef170dd 100644 --- a/holoviews/plotting/bokeh/chart.py +++ b/holoviews/plotting/bokeh/chart.py @@ -265,7 +265,7 @@ class SideHistogramPlot(ColorbarPlot, HistogramPlot): def get_data(self, element, ranges=None, empty=None): if self.invert_axes: - mapping = dict(top='left', bottom='right', left=0, right='top') + mapping = dict(top='right', bottom='left', left=0, right='top') else: mapping = dict(top='top', bottom=0, left='left', right='right') From 01df7a90070541c4eaa3217cfbb4a77b14e6db33 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 12 Oct 2016 14:21:45 +0100 Subject: [PATCH 2/3] Added log option to histogram operation --- holoviews/operation/element.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/holoviews/operation/element.py b/holoviews/operation/element.py index 89de1c6021..ef64143a3d 100644 --- a/holoviews/operation/element.py +++ b/holoviews/operation/element.py @@ -478,6 +478,9 @@ class histogram(ElementOperation): individually = param.Boolean(default=True, doc=""" Specifies whether the histogram will be rescaled for each Raster in a UniformNdMapping.""") + log = param.Boolean(default=False, doc=""" + Whether to apply log scaling """) + mean_weighted = param.Boolean(default=False, doc=""" Whether the weighted frequencies are averaged.""") @@ -518,16 +521,21 @@ def _process(self, view, key=None): if hist_range == (0, 0): hist_range = (0, 1) data = data[np.invert(np.isnan(data))] + if self.p.log: + bin_min = max([abs(hist_range[0]), data[data>0].min()]) + edges = np.logspace(np.log10(bin_min), np.log10(hist_range[1]), + self.p.num_bins+1) + else: + edges = np.linspace(hist_range[0], hist_range[1], self.p.num_bins + 1) normed = False if self.p.mean_weighted and self.p.weight_dimension else self.p.normed try: hist, edges = np.histogram(data[np.isfinite(data)], normed=normed, - range=hist_range, weights=weights, bins=self.p.num_bins) + range=hist_range, weights=weights, bins=edges) if not normed and self.p.weight_dimension and self.p.mean_weighted: hist_mean, _ = np.histogram(data[np.isfinite(data)], normed=normed, range=hist_range, bins=self.p.num_bins) hist /= hist_mean except: - edges = np.linspace(hist_range[0], hist_range[1], self.p.num_bins + 1) hist = np.zeros(self.p.num_bins) hist[np.isnan(hist)] = 0 From cdd82926916064325b230a9f9e5440d291ae823b Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Wed, 12 Oct 2016 14:37:09 +0100 Subject: [PATCH 3/3] Small fix to histogram log option docstring --- holoviews/operation/element.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/holoviews/operation/element.py b/holoviews/operation/element.py index ef64143a3d..7a782adb9e 100644 --- a/holoviews/operation/element.py +++ b/holoviews/operation/element.py @@ -479,7 +479,7 @@ class histogram(ElementOperation): Specifies whether the histogram will be rescaled for each Raster in a UniformNdMapping.""") log = param.Boolean(default=False, doc=""" - Whether to apply log scaling """) + Whether to use base 10 logarithmic samples for the bin edges.""") mean_weighted = param.Boolean(default=False, doc=""" Whether the weighted frequencies are averaged.""")