Skip to content

[FIX] Plot axes: No SI prefix for values below 1 with pyqtgraph 0.14 - #7337

Open
raashish1601 wants to merge 2 commits into
biolab:masterfrom
raashish1601:fix/7272-axis-si-prefix
Open

raashish1601 wants to merge 2 commits into
biolab:masterfrom
raashish1601:fix/7272-axis-si-prefix

Conversation

@raashish1601

Copy link
Copy Markdown
Issue

Fixes #7272

Description of changes

With pyqtgraph 0.14, plot axes without units get an SI prefix for any range below 1, so a Scatter Plot of values between 0 and 1 shows (x0.001) and ticks scaled by 1000. pyqtgraph 0.14 added getSIPrefixEnableRanges, and for axes without units its default is ((0, 1), (1e9, inf)). pyqtgraph 0.13 instead skipped the m and k prefixes for such axes, so nothing was scaled between 1e-3 and 1e6.

StyledAxisItem (the base of Orange's AxisItem, used by Scatter Plot, Line Plot, Bar Plot, heat maps and others) now overrides getSIPrefixEnableRanges and returns ((0, 1e-3), (1e6, inf)) for axes without units, which is the 0.13 behaviour. Axes with units keep pyqtgraph's default. I overrode the getter rather than calling setSIPrefixEnableRanges once, because setLabel (called on every axis update) resets the ranges. pyqtgraph 0.13 never calls this method, so nothing changes there.

Tests: TestAxisItem.test_si_prefix_without_units checks the scale for ranges up to 0.5, 5e5, 5e-4 and 5e6. On pyqtgraph 0.14 it fails without the change (scale 1000 for 0.5) and passes with it; on pyqtgraph 0.13.7 it passes either way. test_plotutils.py, test_owscatterplot.py, test_owlineplot.py, test_owbarplot.py and test_owdistributions.py pass locally (Windows, pyqtgraph 0.14.0, against the Orange 3.40 wheel with this patch applied).

Includes
  • Code changes
  • Tests
  • Documentation

@codecov

codecov Bot commented Oct 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.97%. Comparing base (eea7a75) to head (aec069e).

❌ Your patch check has failed because the patch coverage (75.00%) is below the target coverage (95.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7337      +/-   ##
==========================================
- Coverage   88.98%   88.97%   -0.01%     
==========================================
  Files         337      337              
  Lines       74598    74602       +4     
==========================================
  Hits        66378    66378              
- Misses       8220     8224       +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@janezd janezd added this to the 3.41 milestone Oct 9, 2026
@raashish1601

Copy link
Copy Markdown
Author

Added a test for axes with units, which covers the line codecov flagged. The "Scientific Python nightly wheels" job is unrelated: it fails with ~560 errors from the nightly pyqtgraph (LegendItem.layout is no longer an attribute), and it fails the same way on master (https://github.com/biolab/orange3/actions/runs/37914329734).

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.

Scatter Plot got interesting axis units with pyqtgraph 0.14

3 participants