JuliaPy / PyPlot.jl

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

Can't show figures in Juno (stuck to Agg backend) #413

Closed ghost closed 5 years ago

ghost commented 5 years ago

I'm working with Juno and I can't manage to display figures. I know it's not possible to display figures in the plot pane of Juno, but I also know that I should be able to display plots on separate windows.

Julia is linked to my python distribution : ENV["PYTHON"] = "/path/to/miniconda3/python". After setting this permanently in the startup.jl file, I ran build PyCall; build PyPlot. Before that I did not have any Qt backend (pygui(:qt5) for instance gave an error), but now it seems ok. I modified my matplotlibrc as to put the Qt5Agg backend as default.

Now if I run this code (I tried changing qt to qt5, ion() or not, show() or not, etc..)

using PyCall
pygui(:qt)
using PyPlot
ion()
x = range(0; stop=2*pi, length=1000)
y = sin.(3 * x + 4 * cos.(2 * x))
plot(x, y, color="red", linewidth=2.0, linestyle="--")
show()

I don't get any figure and I have the following warning from matplotlib UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure. % get_backend())

How can I get figures to show then ?

PS: I am on mac

stevengj commented 5 years ago

Maybe try gcf() at the end to get a Figure object (#55) as the result of the executing the code, since Juno hopefully calls display on that and can use the image/png show method?

e-pc commented 5 years ago

@massimilianocomin, make sure you've disabled plot pane in julia client settings.

ghost commented 5 years ago

@stevengj Using gcf() at the end of the code worked perfectly for displaying plots in Juno's plot pane, thanks ! Still, I don't know how to display plots in a separate window.

e-pc commented 5 years ago

image This will definitely show plots in their own windows

ghost commented 5 years ago

@e-pc Thanks, it works perfectly !