Skip to content

allow conditional siPrefixing of axis labels#3136

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
outofculture:3126-sometimes-si
Oct 13, 2024
Merged

allow conditional siPrefixing of axis labels#3136
j9ac9k merged 2 commits intopyqtgraph:masterfrom
outofculture:3126-sometimes-si

Conversation

@outofculture
Copy link
Copy Markdown
Contributor

- siPrefixEnableRanges argument to AxisItem.setLabel and all pass-through callers thereof
- reduce duplication
- f-strings where % were encountered during development
- use ValueError when appropriate
- simplify logic
def setSIPrefixEnableRanges(self, ranges=None):
self._siPrefixEnableRanges = ranges

def getSIPrefixEnableRanges(self):

Check notice

Code scanning / CodeQL

Returning tuples with varying lengths

AxisItem.getSIPrefixEnableRanges returns [tuple of size 1](1) and [tuple of size 2](2).
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Aug 27, 2024

readthedocs failure is due to the following:

Text in column margin in table line 10.

==============  =============================================================
**Arguments:**
text                   The text (excluding units) to display on the label for this
                       axis.
units                  The units for this axis. Units should generally be given
                       without any scaling prefix (eg, 'V' instead of 'mV'). The
                       scaling prefix will be automatically prepended based on the
                       range of data displayed.
unitPrefix             An extra prefix to prepend to the units.
siPrefixEnableRanges   The ranges in which automatic SI prefix scaling is enabled.
                       Defaults to everywhere, unless units is empty, in which case
                       it defaults to ((0, 1), (1e9, inf)).
args                   All extra keyword arguments become CSS style options for
                       the <span> tag which will surround the axis label and units.
==============  =============================================================

Would recommend switching to numpydoc style, some examples here: https://github.com/pyqtgraph/pyqtgraph/blob/master/pyqtgraph/graphicsItems/PlotDataItem.py

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 13, 2024

Thanks @outofculture for the PR and the updating of the docstring format <3

@j9ac9k j9ac9k merged commit 9e45344 into pyqtgraph:master Oct 13, 2024
j9ac9k pushed a commit to j9ac9k/pyqtgraph that referenced this pull request Mar 25, 2025
* allow conditional siPrefixing of axis labels

- siPrefixEnableRanges argument to AxisItem.setLabel and all pass-through callers thereof
- reduce duplication
- f-strings where % were encountered during development
- use ValueError when appropriate
- simplify logic

* I touched them, therefore update to numpy docstrings; delete trailing whitespace
nstelter-slac added a commit to nstelter-slac/Badger that referenced this pull request Nov 20, 2025
…1)' is label not 'iterations'

seems like new release of pyqtgraph broke the test, in specific: pyqtgraph/pyqtgraph#3136.
related to added 'siPrefixEnableRanges' arg for graph axis labels, which results in the added scaling text "(x0.001)".
nstelter-slac added a commit to nstelter-slac/Badger that referenced this pull request Nov 20, 2025
…1)' is label not 'iterations'

seems like new release of pyqtgraph broke the test, in specific: pyqtgraph/pyqtgraph#3136.

related to added 'siPrefixEnableRanges' arg for graph axis labels, which results in the added scaling text "(x0.001)".
lets update the test itself to pass for both axis label text, so tests can still pass with older pyqtgraph versions.
nstelter-slac added a commit to nstelter-slac/Badger that referenced this pull request Nov 20, 2025
…1)' is label not 'iterations'

seems like new release of pyqtgraph broke the test, in specific: pyqtgraph/pyqtgraph#3136.
related to added 'siPrefixEnableRanges' arg for graph axis labels, which results in the added scaling text "(x0.001)".
lets update the test itself to pass for both axis label text, so tests can still pass with older pyqtgraph versions.

also display testing result (last run on main) on main github page (so easier to tell when tests break)
nstelter-slac added a commit to nstelter-slac/Badger that referenced this pull request Nov 20, 2025
…e, ex: 'iterations (x0.001)' instead of expected 'iterations'

seems like new release of pyqtgraph (0.14.0) broke the test, in specific: pyqtgraph/pyqtgraph#3136.
related to added 'siPrefixEnableRanges' arg for graph axis labels, which results in the added scaling text "(x0.001)".
lets update the test itself to pass for both axis label text, so tests can still pass with older pyqtgraph versions.

also add display of testing result (the last run on main) to github page (so easier to tell when tests break).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request: limit upper/bottom units when auto SI-scaling

2 participants