summaryrefslogtreecommitdiff
path: root/silx/gui/plot/items/histogram.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/plot/items/histogram.py')
-rw-r--r--silx/gui/plot/items/histogram.py36
1 files changed, 21 insertions, 15 deletions
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)