Repository navigation
fix(scale_widget): keep scale geometry when replacing the scale draw - #114
Merged
Merged
Conversation
After replacing the scale draw of an axis (QwtPlot.setAxisScaleDraw), the axis ticks could be misaligned with the grid lines and plot items until the next scale division change: a replot did not fix it. QwtScaleWidget.setScaleDraw passed the alignment, the scale division and the transformation of the previous scale draw to the new one, but not its position and length. layoutScale() then computed the border distance hint from a zero-length scale (half the width of the end labels instead of 0) and laid the axis out with it, while the stored border distances used by QwtPlot.canvasMap() were left unchanged. On the next replot, updateAxes() set the same border distances again, which did nothing. - setScaleDraw: also pass the position and the length of the previous scale draw to the new one before laying it out. - Regression tests on the horizontal (reproducing the issue) and vertical axes: geometry kept, axis ends equal to the canvas map ends. - Changelog entry. Fixes #113 Assisted-by: Claude Opus 5.5
This was referenced Oct 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After replacing the scale draw of an axis (
QwtPlot.setAxisScaleDraw), the axis ticks could be misaligned with the grid lines and plot items, until the next scale division change (pan, zoom): a replot did not fix it. This was observed in DataLab, which replaces the bottom scale draw when refreshing its signal view.Root cause
QwtScaleWidget.setScaleDrawpassed the alignment, the scale division and the transformation of the previous scale draw to the new one, but not its position and length.layoutScale()then computed the border distance hint from a zero-length scale (half the width of the end labels instead of0) and laid the axis out with it, while the stored border distances, used byQwtPlot.canvasMap()for grid lines and plot items, were left unchanged. On the next replot,QwtPlot.updateAxes()set the same border distances again, which did nothing.Changes
QwtScaleWidget.setScaleDraw: also pass the position and the length of the previous scale draw to the new one before laying it out.qwt/tests/test_issue113_scaledraw_geometry.py: regression tests on the horizontal and vertical axes (geometry kept after replacement; axis ends equal to the canvas map ends after a replot).CHANGELOG.md: entry in the unreleased bug fixes.Tests
masterfor the horizontal axis (e.g. axis ends 42/483 vs canvas map ends -1/516) and pass with the fix; the vertical axis case passes before and after (regression guard).develop) with this branch: 399 passed, 16 skipped.step.npygives an X axis aligned with the grid, without any DataLab change.Fixes #113