-
Notifications
You must be signed in to change notification settings - Fork 80
silx.gui.plot.PlotWidget: Added yaxis arcsinh support with matplotlib backend #4306
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 |
|---|---|---|
|
|
@@ -1321,6 +1321,17 @@ def setYAxisLogarithmic(self, flag): | |
| self.ax.set_yscale("linear") | ||
| self.ax.yaxis.set_major_formatter(DefaultTickFormatter()) | ||
|
|
||
| def setYAxisArcsinh(self, flag): | ||
| if flag: | ||
| self.ax2.set_yscale("asinh") | ||
| self.ax.set_yscale("asinh") | ||
| return | ||
|
|
||
| self.ax2.set_yscale("linear") | ||
| self.ax2.yaxis.set_major_formatter(DefaultTickFormatter()) | ||
| self.ax.set_yscale("linear") | ||
| self.ax.yaxis.set_major_formatter(DefaultTickFormatter()) | ||
|
Comment on lines
+1324
to
+1333
Member
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. Would be best to change the backend to have a single place where to set scale for yaxis. The backend are not marked as private with an |
||
|
|
||
| def setYAxisInverted(self, flag): | ||
| if self.ax.yaxis_inverted() != bool(flag): | ||
| self.ax.invert_yaxis() | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1596,6 +1596,9 @@ def setYAxisLogarithmic(self, flag): | |||||
| self._plotFrame.yAxis.isLog = flag | ||||||
| self._plotFrame.y2Axis.isLog = flag | ||||||
|
|
||||||
| def setYAxisArcsinh(self, flag): | ||||||
| ... | ||||||
|
Member
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.
Suggested change
|
||||||
|
|
||||||
| def setYAxisInverted(self, flag): | ||||||
| if flag != self._plotFrame.isYAxisInverted: | ||||||
| self._plotFrame.isYAxisInverted = flag | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,10 @@ class Axis(qt.QObject): | |
| LOGARITHMIC = "log" | ||
| """Constant defining a logarithmic scale""" | ||
|
|
||
| _SCALES = {LINEAR, LOGARITHMIC} | ||
| ARCSINH = "arcsinh" | ||
| """Constant defining an arcsinh scale""" | ||
|
|
||
| _SCALES = {LINEAR, LOGARITHMIC, ARCSINH} | ||
|
|
||
| sigInvertedChanged = qt.Signal(bool) | ||
| """Signal emitted when axis orientation has changed""" | ||
|
|
@@ -242,7 +245,6 @@ def setScale(self, scale): | |
| for item in plot.getItems(): | ||
| item._updated() | ||
| plot._invalidateDataRange() | ||
|
|
||
| if scale == self.LOGARITHMIC: | ||
| self._internalSetLogarithmic(True) | ||
| if vmin <= 0: | ||
|
|
@@ -254,6 +256,8 @@ def setScale(self, scale): | |
| self.setLimits(dataRange[0], vmax) | ||
| else: | ||
| self.setLimits(*dataRange) | ||
| elif scale == self.ARCSINH: | ||
| self._internalSetArcsinh(True) | ||
| elif scale == self.LINEAR: | ||
| self._internalSetLogarithmic(False) | ||
| else: | ||
|
|
@@ -451,6 +455,9 @@ def _internalSetLimits(self, ymin, ymax): | |
| def _internalSetLogarithmic(self, flag): | ||
| self._getBackend().setYAxisLogarithmic(flag) | ||
|
|
||
| def _internalSetArcsinh(self, flag): | ||
| self._getBackend().setYAxisArcsinh(flag) | ||
|
Comment on lines
+458
to
+459
Member
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. Same as above, |
||
|
|
||
| def setInverted(self, flag=True): | ||
| """Set the axis orientation. | ||
|
|
||
|
|
||
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.
Adding a new axis scaling changes its control from a boolean to an enum (it should have been so since the beginning).
It would make sense to me to replace
yAxisLogarithmicActionwith a toolbutton with a drop-down.