8000 GitHub · Where software is built
[go: up one dir, main page]

Skip to content
[Bug]: removing already extablished axis sharing #28345
Open
@rdg-netra

Description

@rdg-netra

Bug summary

I have not been able to find a supported method for removing axis sharing that has already been established. At least, not without removing and re-creating the axis.

In older versions of matplotlib, it was possible to do:
ax1.get_shared_x_axes().remove(ax2)
but with the new axis grouper API, this is no longer possible ('GrouperView' object has no attribute 'remove').

There does seem to be a workaround using an internal variable:
ax1._shared_axes['x'].remove(ax2)

I would suggest that a natural way to support removing all axis sharing might be a method:

ax.set_shared_xaxis(None)

or possibly

ax.sharex(None)

Code for reproduction

import matplotlib.pyplot as plt

fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True)
ax1.plot([0, 1, 2], [1, 2, 3])
ax2.plot([0, 1, 2], [3, 2, 1])

ax1.set_shared_xaxis(None)

plt.show()

Actual outcome

AttributeError: 'Axes' object has no attribute 'set_shared_xaxis'.

Expected outcome

Axis sharing should not be enabled.

Additional information

No response

Operating system

No response

Matplotlib Version

3.8.2

Matplotlib Backend

No response

Python version

3.10.13

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0