diff --git a/extra_foam/gui/plot_widgets/tests/test_plot_items.py b/extra_foam/gui/plot_widgets/tests/test_plot_items.py index 90ba13d2..a58890a0 100644 --- a/extra_foam/gui/plot_widgets/tests/test_plot_items.py +++ b/extra_foam/gui/plot_widgets/tests/test_plot_items.py @@ -92,15 +92,16 @@ def testCurvePlotItem(self, dtype): item.setData(np.arange(2).astype(dtype), np.arange(3).astype(dtype)) # test log mode + plot_bottom_right = np.log10(float(x[-1])) self._widget._plot_area._onLogXChanged(True) if dtype == float: _display() - assert item.boundingRect() == QRectF(0, 0, 1.0, 13.5) + assert item.boundingRect() == QRectF(0, 0, plot_bottom_right, 13.5) self._widget._plot_area._onLogYChanged(True) if dtype == float: _display() assert item.boundingRect().topLeft() == QPointF(0, 0) - assert item.boundingRect().bottomRight().x() == 1.0 + assert item.boundingRect().bottomRight().x() == plot_bottom_right assert 1.2 > item.boundingRect().bottomRight().y() > 1.1 # clear data diff --git a/extra_foam/gui/pyqtgraph/graphicsItems/GraphicsObject.py b/extra_foam/gui/pyqtgraph/graphicsItems/GraphicsObject.py index 03d949f3..7bca380a 100644 --- a/extra_foam/gui/pyqtgraph/graphicsItems/GraphicsObject.py +++ b/extra_foam/gui/pyqtgraph/graphicsItems/GraphicsObject.py @@ -129,7 +129,7 @@ def toLogScale(arr, policy=None): """Convert array result to logarithmic scale.""" ret = np.nan_to_num(arr) ret[ret < 0] = 0 - return np.log10(ret + 1) + return np.log10(ret, where=(ret > 0)) def name(self): """An identity of the PlotItem.