PyPlot.jl
PyPlot.jl copied to clipboard
Can't writemime plots
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?
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").
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.