Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[ENH]: Remove artists from axes completely. #25168

Copy link
Copy link
Open
@komoto48g

Description

@komoto48g
Issue body actions

Problem

Calling art.remove() doesn't seem to completely detach the art from the original axes.
In the following sample code, when removing the art from axes (say ax1) and adding it to other axes (say ax2), the ax2 will not draw the art.

import numpy as np
from matplotlib import patches
from matplotlib import pyplot as plt

data = np.random.rand(5,5)

fig = plt.figure()
ax1, ax2 = fig.subplots(1,2)
ax1.imshow(data, interpolation='nearest', cmap='gray',)
ax2.imshow(data, interpolation='bilinear', cmap='gray',)
if 1:
    art = patches.Circle((2, 2), 2, fill=0)
    ax1.add_artist(art)
    art.remove()
    ax2.add_artist(art)
plt.show()

This issue was raised on: Discrouse matplotlib.

Proposed solution

The following line is suggested to be added after `art.remove()':

art.set_transform(ax2.transData)

or

art._transformSet = False

should be added in the art.remove method.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.