Skip to content

Correctly handle SI-prefixes for nonlinear units#3394

Merged
j9ac9k merged 5 commits intopyqtgraph:masterfrom
oyvindlr:handle_nonlinear_units
Nov 15, 2025
Merged

Correctly handle SI-prefixes for nonlinear units#3394
j9ac9k merged 5 commits intopyqtgraph:masterfrom
oyvindlr:handle_nonlinear_units

Conversation

@oyvindlr
Copy link
Copy Markdown
Contributor

@oyvindlr oyvindlr commented Oct 20, 2025

In cases where your unit has a power different from 1, the SI-prefix scaling becomes incorrect. For instance, 1000 m² will be shown as 1 km², which is off by a factor of 1000. And 1000 s^(-1) certainly is not 1 ks^(-1).
I've implemented a "unitPower" parameter that can be used when creating an axis label. The parameter will work for any power, positive, negative and non-integral.
Fixes #3389 and #3392

@campagnola
Copy link
Copy Markdown
Member

This looks great to me, @oyvindlr! Thanks for adding the unit tests as well.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Nov 15, 2025

Whoops, I mishandled the merge ... let me fix that.

@j9ac9k j9ac9k force-pushed the handle_nonlinear_units branch from 9b5b0af to 346a5b7 Compare November 15, 2025 18:15
@j9ac9k j9ac9k merged commit e2ad9bc into pyqtgraph:master Nov 15, 2025
36 checks passed
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Nov 15, 2025

Thanks for the PR @oyvindlr !

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.

Support for inverse length units

3 participants