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

Can't writemime plots #55

Open
Keno opened this issue May 14, 2014 · 2 comments
Open

Can't writemime plots #55

Keno opened this issue May 14, 2014 · 2 comments

Comments

@Keno
Copy link

Keno commented May 14, 2014

I was expecting to be able to do

open(file->writemime(file,"image/png",PyPlot.streamplot(args...)),"test.png","w"))

In order to save a PyPlot plot (this works for e.g. Gadfly/Winston). Any chance that could be supported?

@stevengj
Copy link
Member

You can do this, but you need to pass a Figure object, e.g. via gcf():

open(file -> writemime(file, "image/png", gcf()), "test.png", "w")

The Matplotlib plotting functions typically don't return the Figure object, e.g. returning a Lines2D object or some such thing; I guess this is because they may refer to only part of the figure. I could change them to return gcf(), of course, but I'm reluctant to change the Matplotlib API too much.

You could also just do savefig("test.png").

@Keno
Copy link
Author

Keno commented May 15, 2014

While I see the rationality of not wanting to change the matplotlib API too much, it's also somewhat annoying (especially since I can't just display() it). Nevertheless, if you can't see a way to make both work (maybe by having display and writemime implicitly draw the whole plot even if passed only part?), I won't complain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants