Plot won't show up though there is no error

I am trying to make a simple plotting with this code provided in documents:

using PyPlot
x = linspace(0,2*pi,1000); y = sin.(3*x + 4*cos.(2*x))
plot(x, y, color="red", linewidth=2.0, linestyle="--")

I only get this output

1-element Array{PyCall.PyObject,1}:
 PyObject <matplotlib.lines.Line2D object at 0x11cf36b90>

I have this problem on a Jupyter Notebook but plot shows up in terminal. Things that I’ve checked so far:
I suspect there is something with interactive mode and gui but I don’t have much knowledge on them. I have both tried ioff and ion before calling however nothing changes.
When I run gcf() after plot, it succesfully shows up. Yet, I think I should be able to do plot without this gcf().

I can provide additional debug info if the necessary command is given.

Can you try without pyplot()? As far as I understand, this is a Plots.jl command, not PyPlot.jl.

Try ioff() after using PyPlot. It turns interactive plotting off, which as of the last time I used Jupyter was necessary for inline plotting. I think gcf() might still be necessary at the end.

1 Like