Fix 7717 - flipped axis orientation bug#7761
Conversation
#7717) `ax.limitRange` could silently flip axis orientation while clamping. When no user range is set, `_cleanRange` installs the DFLTRANGEX = [-1, 6] default, and then `limitRange` applies minallowed/maxallowed on top of that default. If minallowed exceeded the default max (or maxallowed fell below the default min), the clamp produced an inverted range (e.g. minallowed=7 yielded [7, 6]). Downstream, `getAutoRange` inferred `axReverse = true` from this state and reversed the final autoranged output - flipping the axis even though the user never asked for it. Instead of flipping, when clamping collapses or inverts the range, extend the opposite end to preserve the original orientation. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Covers: - minallowed > default range max (the original #7717 case) - minallowed = default range max (degenerate clamp boundary) - minallowed well above default range max - autorange:'reversed' + minallowed (must stay reversed) - maxallowed < default range min (symmetric case) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous baselines locked in the #7717 bug: the non-reversed xaxis panels were rendering with axis ticks in descending order (10, 9, 8, 7, 6). With the limitRange orientation fix, those panels now render in the intended ascending order while the xaxis2 panels (explicit autorange:'reversed') remain descending as expected. Regenerated via kaleido in circleci/python:3.8.9 with: python3 test/image/make_baseline.py = allowed-range allowed-range-small Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@bpostlethwaite I'm still in the process of reviewing, but looking at the updated image baselines, I think this change is causing In the |
emilykl
left a comment
There was a problem hiding this comment.
@bpostlethwaite I take back my initial comment -- the lower left plot is xaxis which should not be reversed, so the new mock is correct. Likewise for the second mock, the lower right polar plot should not be reversed, so the new mock is correct.
I don't totally follow the logic and I think there's probably a clearer way to handle setting these bounds, but the existing logic is already a bit convoluted so it's not really any worse. LGTM!
Fixes #7717
Root cause
ax.limitRangecould silently flip axis orientation while clamping. When no user range is set,_cleanRangeinstalls theDFLTRANGEX = [-1, 6]default, thenlimitRangeappliesminallowed/maxallowedon top of it. Ifminallowedexceeded the default max (ormaxallowedfell below the default min), the clamp produced an inverted range (e.g.minallowed=7→[7, 6]). Downstream,getAutoRangeinferredaxReverse = truefrom that state and reversed the final output — flipping the axis even though the user never asked for it.Fix
When clamping would collapse or invert the range, extend the opposite end instead of flipping, preserving the original orientation. Explicit
autorange: 'reversed'still reverses as expected.Commits
src/plots/cartesian/set_convert.js(17+/15−)test/jasmine/tests/axes_test.js(+59) coveringminallowedabove default max, at boundary, well above;autorange:'reversed'+minallowed; and the symmetricmaxallowedcaseallowed-range/allowed-range-small— previous PNGs had locked in the bug (non-reversed xaxis panels rendered descending)