-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Use Agg for rendering in the Mac OSX backend #6178
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
Conversation
Nice! Will this make any difference to the requirement for a Python framework build by any chance? It's a significant pain point. |
Unfortunately, this makes no difference with respect to a framework build. Anaconda has a nice workaround to make a build that "works both ways" (it's not really a framework build, but it has a .app wrapper). I think overtime other distros will probably adopt a similar approach. |
Wow! Works on a Retina with Mavericks! Sharp and snappy! |
Yes -- I was just reminded that |
Except wasn't there fundamental conflicts in the design of the macosx On Fri, Mar 18, 2016 at 7:12 AM, Michael Droettboom <
|
_macosx.FigureCanvas.__init__(self, width, height) | ||
|
||
@property | ||
def renderer(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tight_layout looks for get_renderer https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/tight_layout.py#L218 I guess we should either change it or implement get_renderer on top of the property
Seems to work really great |
@efiring I think restore_region and copy_from_bbox will work with agg. With the native implementation, restore_region and copy_from_bbox needed to be done from inside the callback function during the event loop to satisfy Apple's API requirements. As agg has its own image buffer, restore_region and copy_from_bbox can now be done independently of the event loop. |
Animations now work. It's a bit less efficient than it could be -- the blitting to the Agg buffer is for specific rectangles of the image, but the blitting of the figure to the window is always still the entire figure. That could probably be made to work, but I'm not sure how much benefit it would really have -- the real benefit of the animation code is to not draw (vectorize) more than we have to. Blitting is pretty cheap relative to those things. |
My animation code works at good speed with this PR - thanks very much for doing this. |
There is still a problem with lasso_selector_demo.py. The curve is drawn displaced from the cursor by a large fraction of the window size, and everything seems to being getting selected. |
It looks like mouse events aren't being properly scaled by the device scale. |
I'm of two minds on where this should be milestoned as well. It certainly makes it easier to have consistent look-and-feel across the major backends, which is what 2.0 is "about". But I can see it either way. |
It would be great to have this in for 2.0 - it looks like it will make the OSX backend easier to use, and less puzzling to people reading examples and documentation for other backends. |
Given all of the bugs that this addresses, an argument can be made for putting it in 1.5.x! And given how long it is taking us to get 2.0 out, I think that waiting even longer, for 2.1, would be a mistake. |
Considering how large #5718 was, and it still got into 2.x, I don't see a problem including this PR too. |
@mdboom I tried to cherry-pick this to v2.x, but failed--would you take care of that, please? |
Use Agg for rendering in the Mac OSX backend
Cherry-picked to 2.x as e981e1e |
Hi, apologies for asking a 'rookie' question over here. I recently migrated from linux to a retina mac and found the macosx backend to be very slow at rendering stuff. other backends either don't work or display very low resolution graphics. if I understood correctly this is part of the issue that was fixed here. If anyone could give me a suggestion of how to make the qtconsole import matplotlib fine I would greatly appreciate it, thanks! |
Use Agg for rendering in the Mac OSX backend
According to https://matplotlib.org/stable/users/explain/figure/figure_intro.html#saving-figures: > Many types of output are supported, including raster formats like > PNG, GIF, JPEG, TIFF and vector formats like PDF, EPS, and SVG. However, GIF support was broken by matplotlib#6178. Restore GIF support.
* DOC / BUG: Fix savefig to GIF format with .gif suffix According to https://matplotlib.org/stable/users/explain/figure/figure_intro.html#saving-figures: > Many types of output are supported, including raster formats like > PNG, GIF, JPEG, TIFF and vector formats like PDF, EPS, and SVG. However, GIF support was broken by #6178. Restore GIF support. * Update lib/matplotlib/backends/backend_agg.py Co-authored-by: Thomas A Caswell <tcaswell@gmail.com> * Update lib/matplotlib/testing/decorators.py --------- Co-authored-by: Thomas A Caswell <tcaswell@gmail.com>
I got tired of the bug reports about this one, so thought I'd start seeing how hard this would be. Turns out, not very hard.
Based on @mdehoon's desire to deprecate the macosx backend, one option we've thrown about in order to not regress in terms of features, and not require extra dependencies is to pare down the existing macosx backend so all the rendering happens in the Agg backend. This fixes many of the rendering differences, both visual and performance-wise, between the macosx and the *Agg backends.
I've tested on El Cap, and it seems to work just fine in terms of speed. Retina displays are fully supported -- it should work to move a window from a Retina to non-Retina display, but I don't have such a setup to test on.
Cc: @jenshnielsen and @efiring for extra Mac testing -- esp. if you are on earlier versions than El Capitain. If using anaconda, don't forget to run with
pythonw
.