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

Fix stale draws on MacOSX backend #9549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2017
Merged

Conversation

dopplershift
Copy link
Contributor

@dopplershift dopplershift commented Oct 24, 2017

This took awhile to understand and I thought I was going nuts trying to get OSX Core Graphics to clear a rectangle. It turns out the stale drawing was coming from Agg itself. After comparing against Qt5Agg, it turns out that before this PR, MacOSX never called get_renderer with cleared=True, which causes the Agg renderer to clear its buffer; it only happened on resize/dpi change. With this patch, we now pass the stale flag as the value for cleared.

Fixes #8282.

It also turns out that get_renderer was a complete copy of what's in FigureCanvasAgg, so I just nuked the method in FigureCanvasMac.

Testing was accomplished with a slight modification of the code from #8282:

import matplotlib.pyplot as plt
fig,ax = plt.subplots(facecolor='none')
ax.set_facecolor('none')

plt.subplots_adjust(left=0.25, bottom=0.25)
plt.axis([0, 4, 0,2])
l, = ax.plot([1,2,3],[1,0,1])
ax.set_title('down')
def update():
    l.set_ydata([1,2,1])
    ax.set_title('up')

plt.pause(1.0)
update()
plt.pause(1.0)
plt.show()

Before this patch, you get a diamond-shaped plot and titles overlaid. After, the whole plot changes between subsequent draws.

The contents of this method are identical to those in FigureCanvasAgg,
which is a superclass of FigureCanvasMac, so just remove it.
Unlike on other backends (like Qt), MacOSX backend was never telling the
renderer to clear. This resulted in draws that would happen on top of
the previous Agg buffer. It seems enough to clear the renderer if the
figure is stale.
@dopplershift
Copy link
Contributor Author

Ping @jklymak since you were able to test my last one.

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works with pythonw for me. One down v and then and up ^

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me too! (feel free to ping me in future if you need an osx tester)

@dstansby dstansby merged commit 8cd3eaf into matplotlib:master Oct 24, 2017
@dopplershift dopplershift deleted the fix-8282 branch October 24, 2017 15:38
NelleV added a commit that referenced this pull request Oct 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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