Skip to content
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

slow rendering with backend_macosx on El Capitan #5964

Closed
efiring opened this issue Feb 3, 2016 · 6 comments
Closed

slow rendering with backend_macosx on El Capitan #5964

efiring opened this issue Feb 3, 2016 · 6 comments
Milestone

Comments

@efiring
Copy link
Member

efiring commented Feb 3, 2016

With a fresh installation of mpl 1.5.1 from Anaconda on a new Macbook Air with El Capitan, there are long delays (several seconds) when rendering a multi-subplot figure based on cut/paste a section of script into an ipython window. This does not occur with the qt4agg backend.
I think we need to ensure the macosx backend is not selected by default, at least in the next mpl release on Anaconda.

@efiring efiring added this to the 1.5.2 (Critical bug fix release) milestone Feb 3, 2016
@mdboom
Copy link
Member

mdboom commented Feb 3, 2016

Did this also happen on Mavericks, or is it new to El Capitan? (I'm still on Mavericks, so can confirm one way or the other if you can provide a script to reproduce...)

Is the copy-and-paste into IPython window critical, or does it also happen when running as a script?

@efiring
Copy link
Member Author

efiring commented Feb 5, 2016

It can be demonstrated with the script below, so it does not depend on cut/paste. On a new Macbook Air, part of the plot is displayed, it pauses, and then displays the rest. On Macbook Pro Retina machines, one with Mavericks and the other with Yosemite, it doesn't display anything until the plot is complete. On the Mavericks machine (mine) I can hear the fan and see the power consumption, so evidently it is working rather than waiting. Contrary to my initial guess, I think we are just seeing slower rendering of a very large number of points with the macosx backend compared to any agg backend. I suspect this has always been the case.
Nevertheless, I think this is one more reason for discouraging use of the macosx backend whenever an alternative is available--as it is in any Anaconda installation.

#/usr/bin/env python

import sys
backend = sys.argv[1]

import matplotlib
matplotlib.use(backend)

import matplotlib.pyplot as plt
import numpy as np

fig, axs = plt.subplots(nrows=3)
nw = 101
n = 300000
x = np.arange(n, dtype=float)
y = np.cumsum(np.random.randn(n))
w = np.ones(nw, float) / nw
y = np.convolve(y, w, mode='same')

axs[0].plot(x, y, '.')
axs[1].plot(x, y, '.')
axs[2].plot(x, y, '.')

plt.show()

@tacaswell
Copy link
Member

This is not super snappy with Agg

In [12]: %timeit fig.canvas.draw()
1 loops, best of 3: 691 ms per loop

Switching to using pixel markers (',') gives

In [14]: %timeit fig.canvas.draw()
10 loops, best of 3: 123 ms per loop

and using a line (with no markers) gives

In [16]: %timeit fig.canvas.draw()
10 loops, best of 3: 59.3 ms per loop

Using 'o' as the marker is worse

In [18]: %timeit fig.canvas.draw()
1 loops, best of 3: 1.16 s per loop

@efiring
Copy link
Member Author

efiring commented Feb 5, 2016

On my Retina with the '.' marker and macosx:

 In [15]: %timeit fig.canvas.draw()
1 loops, best of 3: 58.9 s per loop

and with qt4agg:

In [15]: %timeit fig.canvas.draw()
1 loops, best of 3: 614 ms per loop

It will be interesting to see how qt5agg handles it when that becomes available; according to @mdboom, it will support the full resolution, while qt4agg is operating in lo-res mode.
Presumably it will be something like the result of saving a png at high dpi:

In [16]: %timeit fig.savefig('test.png', dpi=320)
1 loops, best of 3: 4.26 s per loop

@efiring
Copy link
Member Author

efiring commented Mar 16, 2016

I switched the milestone to "unassigned" because this is not something we can fix in the present macosx backend. The solution will be to use an agg-based backend, either a presently existing one, or a modification of macosx to use agg.

@mdboom
Copy link
Member

mdboom commented Mar 21, 2016

Fixed by #6178

@QuLogic QuLogic modified the milestones: 2.0 (style change major release), unassigned Mar 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants