diff options
Diffstat (limited to 'silx/gui/plot/items/histogram.py')
-rw-r--r-- | silx/gui/plot/items/histogram.py | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/silx/gui/plot/items/histogram.py b/silx/gui/plot/items/histogram.py index 935f8d5..5941cc6 100644 --- a/silx/gui/plot/items/histogram.py +++ b/silx/gui/plot/items/histogram.py @@ -38,7 +38,7 @@ try: except ImportError: # Python2 support import collections as abc -from .core import (Item, AlphaMixIn, BaselineMixIn, ColorMixIn, FillMixIn, +from .core import (DataItem, AlphaMixIn, BaselineMixIn, ColorMixIn, FillMixIn, LineMixIn, YAxisMixIn, ItemChangedType) _logger = logging.getLogger(__name__) @@ -100,7 +100,7 @@ def _getHistogramCurve(histogram, edges): # TODO: Yerror, test log scale -class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, +class Histogram(DataItem, AlphaMixIn, ColorMixIn, FillMixIn, LineMixIn, YAxisMixIn, BaselineMixIn): """Description of an histogram""" @@ -119,7 +119,7 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, _DEFAULT_BASELINE = None def __init__(self): - Item.__init__(self) + DataItem.__init__(self) AlphaMixIn.__init__(self) BaselineMixIn.__init__(self) ColorMixIn.__init__(self) @@ -157,8 +157,8 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, (x <= 0) if xPositive else False, (y <= 0) if yPositive else False) # Make a copy and replace negative points by NaN - x = numpy.array(x, dtype=numpy.float) - y = numpy.array(y, dtype=numpy.float) + x = numpy.array(x, dtype=numpy.float64) + y = numpy.array(y, dtype=numpy.float64) x[clipped] = numpy.nan y[clipped] = numpy.nan @@ -187,17 +187,17 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, yPositive = False if xPositive or yPositive: - values = numpy.array(values, copy=True, dtype=numpy.float) + values = numpy.array(values, copy=True, dtype=numpy.float64) if xPositive: # Replace edges <= 0 by NaN and corresponding values by NaN clipped_edges = (edges <= 0) - edges = numpy.array(edges, copy=True, dtype=numpy.float) + edges = numpy.array(edges, copy=True, dtype=numpy.float64) 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) + clipped_values = numpy.zeros_like(values, dtype=bool) if yPositive: # Replace values <= 0 by NaN, do not modify edges @@ -219,19 +219,6 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, min(0, numpy.nanmin(values)), max(0, numpy.nanmax(values))) - def setVisible(self, visible): - """Set visibility of item. - - :param bool visible: True to display it, False otherwise - """ - visible = bool(visible) - # TODO hackish data range implementation - 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 @@ -314,11 +301,7 @@ class Histogram(Item, AlphaMixIn, ColorMixIn, FillMixIn, self._alignement = align self._setBaseline(baseline) - if self.isVisible(): - plot = self.getPlot() - if plot is not None: - plot._invalidateDataRange() - + self._boundsChanged() self._updated(ItemChangedType.DATA) def getAlignment(self): |