-
Notifications
You must be signed in to change notification settings - Fork 82
silx.gui.plot: Fixed axis scales #4643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,7 +109,6 @@ def __init__( | |
| resetzoom=True, | ||
| autoScale=True, | ||
| logScale=True, | ||
| chooseScale=False, | ||
| grid=True, | ||
| curveStyle=True, | ||
| colormap=True, | ||
|
|
@@ -123,6 +122,7 @@ def __init__( | |
| roi=True, | ||
| mask=True, | ||
| fit=False, | ||
| axisScales=False, | ||
| ): | ||
| super().__init__(parent=parent, backend=backend) | ||
| if parent is None: | ||
|
|
@@ -186,14 +186,14 @@ def __init__( | |
| self.yAxisLogarithmicAction.setVisible(logScale) | ||
| self.addAction(self.yAxisLogarithmicAction) | ||
|
|
||
| self.xAxisScaleButton = PlotToolButtons.XAxisScaleToolButton( | ||
| self._xAxisScaleButton = PlotToolButtons.XAxisScaleToolButton( | ||
| parent=self, plot=self | ||
| ) | ||
| self.xAxisScaleButton.setVisible(chooseScale) | ||
| self.yAxisScaleButton = PlotToolButtons.YAxisScaleToolButton( | ||
| self._xAxisScaleButton.setVisible(axisScales) | ||
| self._yAxisScaleButton = PlotToolButtons.YAxisScaleToolButton( | ||
| parent=self, plot=self | ||
| ) | ||
| self.yAxisScaleButton.setVisible(chooseScale) | ||
| self._yAxisScaleButton.setVisible(axisScales) | ||
|
|
||
| self.gridAction = self.group.addAction( | ||
| actions.control.GridAction(self, gridMode="both", parent=self) | ||
|
|
@@ -487,12 +487,8 @@ def _createToolBar(self, title, parent): | |
| self.yAxisInvertedAction = toolbar.insertWidget( | ||
| self.colorbarAction, self.yAxisInvertedButton | ||
| ) | ||
| self.xAxisScaleAction = toolbar.insertWidget( | ||
| self.colorbarAction, self.xAxisScaleButton | ||
| ) | ||
| self.yAxisScaleAction = toolbar.insertWidget( | ||
| self.colorbarAction, self.yAxisScaleButton | ||
| ) | ||
| toolbar.insertWidget(self.gridAction, self._xAxisScaleButton) | ||
| toolbar.insertWidget(self.gridAction, self._yAxisScaleButton) | ||
| return toolbar | ||
|
|
||
| def saveGraph( | ||
|
|
@@ -782,6 +778,12 @@ def getYAxisLogarithmicAction(self): | |
| """ | ||
| return self.yAxisLogarithmicAction | ||
|
|
||
| def getXAxisScaleButton(self) -> PlotToolButtons.XAxisScaleToolButton: | ||
| return self._xAxisScaleButton | ||
|
|
||
| def getYAxisScaleButton(self) -> PlotToolButtons.YAxisScaleToolButton: | ||
| return self._yAxisScaleButton | ||
|
|
||
|
Comment on lines
+781
to
+786
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make attributes added in #4529 private and expose them through methods |
||
| def getGridAction(self): | ||
| """Action to toggle the grid visibility in the plot | ||
|
|
||
|
|
@@ -923,7 +925,7 @@ def __init__(self, parent=None, backend=None): | |
| resetzoom=True, | ||
| autoScale=True, | ||
| logScale=False, | ||
| chooseScale=True, | ||
| axisScales=True, | ||
| grid=True, | ||
| curveStyle=True, | ||
| colormap=False, | ||
|
|
@@ -975,7 +977,7 @@ def __init__(self, parent=None, backend=None): | |
| resetzoom=True, | ||
| autoScale=False, | ||
| logScale=False, | ||
| chooseScale=False, | ||
| axisScales=False, | ||
| grid=False, | ||
| curveStyle=False, | ||
| colormap=True, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,9 +78,6 @@ class Axis(qt.QObject): | |
| sigScaleChanged = qt.Signal(str) | ||
| """Signal emitted when axis scale has changed""" | ||
|
|
||
| _sigLogarithmicChanged = qt.Signal(bool) | ||
| """Signal emitted when axis scale has changed to or from logarithmic""" | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. legacy unused signal |
||
| sigAutoScaleChanged = qt.Signal(bool) | ||
| """Signal emitted when axis autoscale has changed""" | ||
|
|
||
|
|
@@ -231,13 +228,10 @@ def setScale(self, scale: AxisScaleType): | |
| return | ||
|
|
||
| # For the backward compatibility signal | ||
| emitLog = self._scale == self.LOGARITHMIC or scale == self.LOGARITHMIC | ||
| self._scale = scale | ||
| self._internalSetScale() | ||
|
|
||
| self.sigScaleChanged.emit(self._scale) | ||
| if emitLog: | ||
| self._sigLogarithmicChanged.emit(self._scale == self.LOGARITHMIC) | ||
|
|
||
| def _isLogarithmic(self) -> bool: | ||
| """Return True if this axis scale is logarithmic, False if linear.""" | ||
|
|
@@ -405,6 +399,7 @@ def _internalSetScale(self): | |
| for item in plot.getItems(): | ||
| item._updated() | ||
| plot._invalidateDataRange() | ||
| plot._setDirtyPlot() | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make sure plot is updated when changing axis scale |
||
|
|
||
| if scale == self.LOGARITHMIC: | ||
| self._getBackend().setXAxisScale(scale="log") | ||
|
|
@@ -470,6 +465,8 @@ def _internalSetScale(self): | |
| for item in plot.getItems(): | ||
| item._updated() | ||
| plot._invalidateDataRange() | ||
| plot._setDirtyPlot() | ||
|
|
||
| if scale == self.LOGARITHMIC: | ||
| self._getBackend().setYAxisScale(scale="log") | ||
| if vmin <= 0: | ||
|
|
@@ -539,7 +536,6 @@ def __init__(self, plot, mainAxis): | |
| self.__mainAxis = mainAxis | ||
| self.__mainAxis.sigInvertedChanged.connect(self.sigInvertedChanged.emit) | ||
| self.__mainAxis.sigScaleChanged.connect(self.sigScaleChanged.emit) | ||
| self.__mainAxis._sigLogarithmicChanged.connect(self._sigLogarithmicChanged.emit) | ||
| self.__mainAxis.sigAutoScaleChanged.connect(self.sigAutoScaleChanged.emit) | ||
|
|
||
| def _internalSetCurrentLabel(self, label): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved as last argument to be fully backward compatible + renamed to be inline with other argument names