Skip to content

Conversation

@mrinalcodez
Copy link

@mrinalcodez mrinalcodez commented Jul 24, 2025

PR summary

Quick fix for shared axis warning during .clear()

This PR implements a minimal, targeted fix for issue #30159, where calling .clear() on a shared axes — particularly with log scale — results in:

  • Limits being reset to (0, 1), which is invalid in log scale
  • Warnings emitted due to improper propagation of limits

This patch does a quick fix for the warnings in the issue but does not fully implement the proposed fix in issue #28851

What does this fix do?

  • Prevents resetting axis limits and scale in .clear() if the axis is shared
  • Ensures .clear() only clears data-like elements (lines, text, collections), not layout or shared state

What this does not do?

  • This does not define long-term .clear() semantics

PR checklist

@mrinalcodez
Copy link
Author

Hi! I wanted to check on the status of this PR.
I believe it addresses the issue as discussed, but I’m happy to revise anything if needed.
Thanks for your time!

@timhoffm
Copy link
Member

timhoffm commented Nov 16, 2025

Sorry for not replying back. This is a difficult topic and per #30159 (comment)

This would be more consistent, but not necessarily a desired behavior (see #28851 (comment)).

I'm not convinced this is an improvement. Unless we have a clear understanding on the meaning of clearing shared axes, I'm very hesitant to do any changes.

For now, I'd claim that clearing of shared axes is undefined behavior. Maybe the right way to go about this is making it possible to un-share and re-share axes. Then, un-share > clear > re-share has well-defined semantics.

A better step towards consistency is likely to remove the internal asymmetry defined through _sharex / _sharey; see #30159 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

[Bug]: Calling axes.clear() on a shared y or x-axis issues an unexpected warning with log scale

2 participants