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
backend_cairo.py -- added print_surface method #1254
Conversation
Added ability to print to a supplied cairo surface. It was the least hackish way I could interface matplotlib and mapnik.
@@ -435,6 +435,16 @@ def print_svg(self, fobj, *args, **kwargs): | |||
|
|||
def print_svgz(self, fobj, *args, **kwargs): | |||
return self._save(fobj, 'svgz', *args, **kwargs) | |||
|
|||
def print_surface(self, fobj, *args, **kwargs): |
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.
The other methods, as far as I can tell, are named print_[filetype]
. Since 'surface' is not a filetype, perhaps this function should be called something else? Perhaps this is really nit-picky, though. I have also just realised it doesn't actually save a file, it merely renders it to a canvas. The other print_[filetype]
methods write a physical file to disk. Perhaps render_to_canvas
would be more appropriate?
Maybe some of the other devs could chime in here.
Edit: Perhaps also a docstring describing what fobj
is and what are vaid args and kwargs. On further inspection, it doesn't look like the args and kwargs get passed anywhere. Is this intentional?
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.
Sorry for seeing this late. I think I agree with @dmcdougall here, let's call it "print_to_surface", and the fobj
argument name should be surface
(or whatever the convention is in cairo), since it is definitely not a file object.
It looks like this addition renders the current figure to the canvas. It provides convenience. Therefore, should there be one of these added for all the other backends? |
This is a convenience function for creating a Renderer for an existing canvas (or cairo surface in this specific case). Wouldn't it be better to add this stuff to the RendererCairo then? If you are planning to update a GUI, it's probably more efficient to keep the Renderer instead of recreating it every time.. |
It may just be me because I have never used Cairo, but I still have no clue what it is that this "feature" does. Documentation somewhere would be of great use. At first, I thought this had something to do with mplot3d's plot_surface(). |
Added ability to print to a supplied cairo surface. It was the least hackish way I could interface matplotlib and mapnik.