Skip to content

AttributeError: 'NoneType' object has no attribute 'canvas' #5663

Closed

Description

@dessant

Removing an ax created with twinx/twiny and then adding a new one with a plot, or just setting xlim/ylim for it triggers the crash (twinx -> xlim, twiny -> ylim).

import matplotlib
matplotlib.use('TkAgg')  # same with 'agg'

import matplotlib.pyplot as plt

fig = plt.figure()
ax1 = fig.add_subplot(111)

ax2 = ax1.twinx()
ax2.remove()

ax3 = fig.add_subplot(111)
ax3.set_xlim([1, 5])

plt.show()
Traceback (most recent call last):
  File "E:\dev\prs\main\test2.py", line 13, in <module>
    ax3.set_xlim([1, 5])
  File "e:\dev\envs\py34_x86\Python\lib\site-packages\matplotlib\axes\_base.py", line 2783, in set_xlim
    other.figure.canvas is not None):
AttributeError: 'NoneType' object has no attribute 'canvas'

Activity

  1. added this to the milestone on Dec 13, 2015
  2. tacaswell commented on Dec 13, 2015

    @tacaswell
    Member

    Apparently the remove is not doing enough clean up

    Also note that ax1 is ax3 == True.

  3. modified the milestones: , on Dec 13, 2015
  4. self-assigned this
    on Dec 15, 2015
  5. added a commit that references this issue on Dec 15, 2015
    0245db9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions