Fix flickering, when panning/scrolling in a fully zoomed-out view#2387
Fix flickering, when panning/scrolling in a fully zoomed-out view#2387j9ac9k merged 2 commits intopyqtgraph:masterfrom
Conversation
|
Hi @bbc131 Thanks for the PR, your description of the issue, and the proposed fix. My first thought is we could probably do better than 1.0e-9 as the multiplier, and instead use I would love to get your thoughts on that. |
|
Hi @j9ac9k, sorry for replying only now, was absent for a while. I guess you mean something like "consider as changed if view differs by more than a x-th of a pixel". At the first glance I would say this would be easier to understand, but in essence it's more or less the same. You also can't circumvent to define some factor. |
|
Hi @bbc131 No need to apologize! This looks good to me, only change I would request then is to explicitly state in your comment that 1.0e-9 was chosen arbitrarily to address floating point errors. When I see constants like that in the code-base I periodically wonder if there was a specific reason that was chosen or not. I'm good w/ not using |
|
LGTM, thanks for the PR! |
…qtgraph#2387) * Fix flickering, when panning/scrolling in a fully zoomed-out view * Add comment to explain chosen factor
…qtgraph#2387) * Fix flickering, when panning/scrolling in a fully zoomed-out view * Add comment to explain chosen factor
If a
ViewBoxis fully zoomed out (i.e. the current view range equals to the limits), it's still possible to pan the view.The values by which the views range changes are extremely small (less than 1e-14), but still this is source of at least some imperfections. Issues I observed are that the
ViewBox.sigRangeChangedis emitted and that plot or axis might flicker.Fix
In
ViewBox.updateViewRangethe desired view range values are compared with the current view range values and if they differ, theViewBox.sigRangeChangedis emitted.To solve the issue, I replaced the direct comparison of the view-range-values with a threshold based comparison.
So only if the difference between new and old values relative to the total visible span exceeds a value of 1.0e-9 it's considered as a actual change.
mwe to reproduce the problem
To reproduce the problems, run the mwe below and follow these steps:
You'll observe that the "0"- and "1"-tick-labels at the x-axis sometimes (dis)appear, depending on which direction you tried to pan the view.
Further, the printed x-range shows values like
x-range: [3.41740524767431e-16, 1.0]orx-range: [0.0, 0.9999999999999996].