Repository navigation
Draw thin curves with a cosmetic pen on screen (fast rendering on HiDPI screens) - #81
Merged
Merged
Conversation
With a display scaling factor such as 150 %, curves and error bars of width 1 were drawn wider than one device pixel, which made Qt's raster engine take its slow path for wide pens (about 800 ms instead of 3 ms for a noisy 2000-point curve). When painting on screen (raster engine without scaling transform), pens of width 1 or less are now made cosmetic at drawing time. The stored pen and curve parameters are unchanged, and printing or exporting (other paint engines or scaled painters) is not affected. The new `curve/cosmetic_hairline` option of the `plot` section restores the previous behavior. Closes #80 Assisted-by: Claude Opus 5.5
This was referenced Oct 29, 2026
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.
Closes #80. Part of DataLab-Platform/DataLab#453 (curve readability).
Problem
With a display scaling factor such as 125 % or 150 %, a curve of width 1.0 is drawn wider than one device pixel, and Qt's raster engine takes its slow path for wide pens. Noisy curves become several hundred times slower to draw.
Change
CurveItem.drawCurve(and the error bars ofErrorBarCurveItem) draws thin pens with a cosmetic copy of the pen, i.e. one device pixel wide, through the newget_screen_pen()helper.QwtPlotRenderer) are not affected.LineStyleParam.width) are unchanged.curve/cosmetic_hairlineoption of theplotconfiguration section (enabled by default) restores the previous behavior.Measurements
Noisy curve, 2000 points, antialiased,
CurveItem.drawSerieson aQImage:Tests
New
plotpy/tests/unit/test_curve_screen_pen.py:The
plotpy/tests/unitandplotpy/tests/itemssuites pass locally, excepttest_edit_point_tool, which also fails locally without this change (mouse simulation).