JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
475 stars 87 forks source link

plots not showing in LightTable #63

Open berceanu opened 10 years ago

berceanu commented 10 years ago

LightTable has support for matplotlib inline plots, I was wondering how to get them to display using PyPlot. In fact I cannot even get it to show a separate plot window atm. I'm using LightTable with the Jewel plugin and Jupiter environment.

https://github.com/one-more-minute/Jupiter-LT

stevengj commented 10 years ago

cc: @one-more-minute; I haven't tried LT yet, so I don't have any experience with this.

PyPlot attempts to do inline plotting whenever displayable returns true for image/png or other supported image formats. In that case, it calls redisplay(fig) from each plotting command.

LightTable's Display subclass should probably overload redisplay(d, x) to add x to a queue of things to display (removing duplicates), and then flush the queue at the end of an input execution, similar to IJulia. See inline.jl, and the undisplay function (which is also called on the result of an input evaluation to avoid displaying the result twice).

berceanu commented 10 years ago

Ok, but for starters I would settle for a separate plotting window being opened. This however does not happen.

stevengj commented 10 years ago

That's because PyPlot thinks that inline display is available. You can run pygui(true) to explicitly force a separate Python plotting window even if there is an inline display.

stevengj commented 10 years ago

Looks like there was a bug in redisplay(x) that may have prevented it from working properly here.

MikeInnes commented 10 years ago

Thanks for letting me know, I'll take a look at this.

jamesdanged commented 9 years ago

This works now. Just call PyPlot's "figure()" method to see results inline.

import PyPlot pplt = PyPlot

x = [x/1000 * 2_pi for x=1:1000] y = sin(3_x + 4_cos(2_x)) pplt.plot(x, y, color="red", linewidth=2.0, linestyle="--") pplt.title("Sample graph") pplt.figure(1)

stevengj commented 9 years ago

figure shouldn't be necessary if redisplay is implemented as I explained above.