You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[ENH]: [Bug]: secondary_xaxes().set_xlim/xbound should warn or raise that it is ineffective #31406
Changing the limits of a main axes will update the secondary axes' limits (at draw time), but changing the limits of a secondary axes has silently no effect (they get again overwritten by the (converted) main limits at draw time, in SecondaryAxes._set_lims). This should at least warn or raise.
Alternatively, secondary axes could set {x,y}lim_changed callbacks in both directions to fully keep limits in sync.
Proposed solution
Warn or raise on ineffective limits updates, or use callbacks to fully keep limits in sync.
Since the second axis contains no data (c.f. #31405 (comment)) I would consider it as subordinate, and therefore it would be ok to not do the forward sync.
It may be a bit hard to warn, because the complementary xaxis is just a regular axis, and intercepting all it's call secax.set_xlim, secax.set_xbounds, secax.axis.set_lim, ... is hard. Likely we'd need a special subclass of XAxis to do that effectively. Therefore, I'd also be ok with only documenting this as part of the Returns docs, i.e. further amending #31405 (comment).
Since the second axis contains no data (c.f. #31405 (comment)) I would consider it as subordinate, and therefore it would be ok to not do the forward sync.
It may be a bit hard to warn, because the complementary xaxis is just a regular axis, and intercepting all it's call secax.set_xlim, secax.set_xbounds, secax.axis.set_lim, ... is hard. Likely we'd need a special subclass of XAxis to do that effectively. Therefore, I'd also be ok with only documenting this as part of the Returns docs, i.e. further amending #31405 (comment).
It makes sense to treat SecondaryAxes as subordinate. It might just help to mention in the docs that setting its limits (like set_xlim/set_ylim) has no effect, since the current silent behaviour can be a bit confusing.
Its limits are derived from the parent Axes via the specified transformation, and setting limits on the secondary axis
(e.g., via ``set_xlim`` or ``set_ylim``) has no effect.
Activity
timhoffm commentedon Mar 27, 2026
Since the second axis contains no data (c.f. #31405 (comment)) I would consider it as subordinate, and therefore it would be ok to not do the forward sync.
It may be a bit hard to warn, because the complementary xaxis is just a regular axis, and intercepting all it's call
secax.set_xlim,secax.set_xbounds,secax.axis.set_lim, ... is hard. Likely we'd need a special subclass of XAxis to do that effectively. Therefore, I'd also be ok with only documenting this as part of the Returns docs, i.e. further amending #31405 (comment).Chirag3841 commentedon Apr 2, 2026
It makes sense to treat SecondaryAxes as subordinate. It might just help to mention in the docs that setting its limits (like
set_xlim/set_ylim) has no effect, since the current silent behaviour can be a bit confusing.in _secondary_axes.py