PyPlot.jl icon indicating copy to clipboard operation
PyPlot.jl copied to clipboard

plots not showing in LightTable

Open berceanu opened this issue 10 years ago • 7 comments

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

berceanu avatar Jun 24 '14 08:06 berceanu

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).

stevengj avatar Jun 24 '14 14:06 stevengj

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

berceanu avatar Jun 24 '14 14:06 berceanu

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 avatar Jun 24 '14 14:06 stevengj

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

stevengj avatar Jun 24 '14 14:06 stevengj

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

MikeInnes avatar Jun 24 '14 14:06 MikeInnes

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)

jamesdanged avatar Nov 28 '14 02:11 jamesdanged

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

stevengj avatar Nov 28 '14 15:11 stevengj