From bfa4dba15485b4192f8bbe13345e9658c97ecf76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Picca=20Fr=C3=A9d=C3=A9ric-Emmanuel?= Date: Sat, 7 Oct 2017 07:59:01 +0200 Subject: New upstream version 0.6.0+dfsg --- silx/gui/plot/items/histogram.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) (limited to 'silx/gui/plot/items/histogram.py') diff --git a/silx/gui/plot/items/histogram.py b/silx/gui/plot/items/histogram.py index c3821bc..ad89677 100644 --- a/silx/gui/plot/items/histogram.py +++ b/silx/gui/plot/items/histogram.py @@ -27,7 +27,7 @@ __authors__ = ["H. Payno", "T. Vincent"] __license__ = "MIT" -__date__ = "02/05/2017" +__date__ = "27/06/2017" import logging @@ -35,7 +35,7 @@ import logging import numpy from .core import (Item, AlphaMixIn, ColorMixIn, FillMixIn, - LineMixIn, YAxisMixIn) + LineMixIn, YAxisMixIn, ItemChangedType) _logger = logging.getLogger(__name__) @@ -139,8 +139,8 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, # Filter-out values <= 0 plot = self.getPlot() if plot is not None: - xPositive = plot.isXAxisLogarithmic() - yPositive = plot.isYAxisLogarithmic() + xPositive = plot.getXAxis()._isLogarithmic() + yPositive = plot.getYAxis()._isLogarithmic() else: xPositive = False yPositive = False @@ -174,8 +174,8 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, plot = self.getPlot() if plot is not None: - xPositive = plot.isXAxisLogarithmic() - yPositive = plot.isYAxisLogarithmic() + xPositive = plot.getXAxis()._isLogarithmic() + yPositive = plot.getYAxis()._isLogarithmic() else: xPositive = False yPositive = False @@ -185,14 +185,19 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, if xPositive: # Replace edges <= 0 by NaN and corresponding values by NaN - clipped = (edges <= 0) + clipped_edges = (edges <= 0) edges = numpy.array(edges, copy=True, dtype=numpy.float) - edges[clipped] = numpy.nan - values[numpy.logical_or(clipped[:-1], clipped[1:])] = numpy.nan + edges[clipped_edges] = numpy.nan + clipped_values = numpy.logical_or(clipped_edges[:-1], + clipped_edges[1:]) + else: + clipped_values = numpy.zeros_like(values, dtype=numpy.bool) if yPositive: # Replace values <= 0 by NaN, do not modify edges - values[values <= 0] = numpy.nan + clipped_values = numpy.logical_or(clipped_values, values <= 0) + + values[clipped_values] = numpy.nan if xPositive or yPositive: return (numpy.nanmin(edges), @@ -211,14 +216,13 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, :param bool visible: True to display it, False otherwise """ - visibleChanged = self.isVisible() != bool(visible) - super(Histogram, self).setVisible(visible) - + visible = bool(visible) # TODO hackish data range implementation - if visibleChanged: + if self.isVisible() != visible: plot = self.getPlot() if plot is not None: plot._invalidateDataRange() + super(Histogram, self).setVisible(visible) def getValueData(self, copy=True): """The values of the histogram @@ -248,7 +252,7 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, :returns: (N histogram value, N+1 bin edges) :rtype: 2-tuple of numpy.nadarray """ - return (self.getValueData(copy), self.getBinEdgesData(copy)) + return self.getValueData(copy), self.getBinEdgesData(copy) def setData(self, histogram, edges, align='center', copy=True): """Set the histogram values and bin edges. @@ -286,3 +290,5 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, self._histogram = histogram self._edges = edges + + self._updated(ItemChangedType.DATA) -- cgit v1.2.3