Plots.jl: Cannot view plots in Plots pane in Juno for JuliaPro 0.6.0.1

Created on 11 Oct 2017  路  13Comments  路  Source: JuliaPlots/Plots.jl

I am getting an error similar to TheFourSymbols. I am on Juno for JuliaPro 0.6.0.1. When I execute the following command in the console:

using Plots
plot(rand(4,4))

I get :

Any[4]
PyObject
PyObject
PyObject
PyObject

and nothing in the Plot pane.

If I add"gui()" to the above commands, I get "
No current plot/subplot
in gui at Plots\src\output.jl:134
in current at Plots\srcplot.jl:15"

Can someone please tell me what I am doing wrong? Here is a screenshot:

image
image

Most helpful comment

Executing the whole script does not produce any plot, however, if I run the plot line only, a plot comes up on the pane. (You didn't set any backend, so by default Plots.jl takes gr(). Notice that gr() and plotlyjs() are not giving any plot pane with the gui() call so far. https://github.com/JuliaPlots/Plots.jl/issues/581)

You could try doing (https://github.com/JuliaPlots/Plots.jl/issues/537):
using Plots
plt = plot(rand(4,4))
display(plt)

It worked for me.

All 13 comments

Executing the whole script does not produce any plot, however, if I run the plot line only, a plot comes up on the pane. (You didn't set any backend, so by default Plots.jl takes gr(). Notice that gr() and plotlyjs() are not giving any plot pane with the gui() call so far. https://github.com/JuliaPlots/Plots.jl/issues/581)

You could try doing (https://github.com/JuliaPlots/Plots.jl/issues/537):
using Plots
plt = plot(rand(4,4))
display(plt)

It worked for me.

Thanks for your quick reply, Inacquaroli. The commands you gave me, again does not show the plot. Instead I get this:

image

Is the warning relevant in this scenario? The console shown here is the Atom console. Are there any setting I am missing?

Thanks in advance.

Try setting one backend at least after using Plots. Depending which one you have installed: pyplot(), plotlyjs(), gr().

Yes, I had tried that earlier, but it didn't help:

image

I feel like I am missing something basic.

The correct syntax is

using Plots
pyplot()

With this backend gui() should do.

Oh sorry about that mess up! But this still won't work :(

image

It looks like you have a using PyPlot somewhere earlier. Try to open a new session and post all the code you're typing.

Ok, I opened a new session and typed:

using Plots
pyplot()
WARNING: Couldn't initialize pyplot. (might need to install it?)
INFO: To do a standard install of pyplot, copy and run this:

if !Plots.is_installed("PyPlot")
Pkg.add("PyPlot")
end
withenv("PYTHON" => "") do
Pkg.build("PyPlot")
end

now restart julia!

InitError: PyCall.PyError("ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)", PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x000000005c9a23e0), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x0000000035869e48), PyCall.PyObject(Ptr{PyCall.PyObject_struct} @0x0000000000000000))

plt = plot(rand(4,4))
display(plt)
WARNING: Couldn't initialize pyplot. (might need to install it?)
INFO: To do a standard install of pyplot, copy and run this:

if !Plots.is_installed("PyPlot")
Pkg.add("PyPlot")
end
withenv("PYTHON" => "") do
Pkg.build("PyPlot")
end

now restart julia!

PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name))

if !Plots.is_installed("PyPlot")
Pkg.add("PyPlot")
end
withenv("PYTHON" => "") do
Pkg.build("PyPlot")
end
INFO: Building Conda
INFO: Building PyCall
INFO: Using the Python distribution in the Conda package by default.
To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").
WARNING:
Compat.UTF8String is deprecated, use String instead.
likely near C:\Users\sparimal\AppData\Local\JuliaPro-0.6.0.1pkgs-0.6.0.1\v0.6\PyCall\deps\build.jl:184
INFO: PyCall is using C:\Users\sparimal\AppData\Local\JuliaPro-0.6.0.1pkgs-0.6.0.1\v0.6\Conda\deps\usrpython.exe (Python 2.7.13) at C:\Users\sparimal\AppData\Local\JuliaPro-0.6.0.1pkgs-0.6.0.1\v0.6\Conda\deps\usrpython.exe, libpython = C:\Users\sparimal\AppData\Local\JuliaPro-0.6.0.1pkgs-0.6.0.1\v0.6\Conda\deps\usrpython27
INFO: C:\Users\sparimal\AppData\Local\JuliaPro-0.6.0.1pkgs-0.6.0.1\v0.6\PyCall\deps\deps.jl has not changed
INFO: C:\Users\sparimal\AppData\Local\JuliaPro-0.6.0.1pkgs-0.6.0.1\v0.6\PyCall\deps\PYTHON has not changed

pyplot()
plt = plot(rand(4,4))
display(plt)
WARNING: redefining constant pycolors
WARNING: redefining constant pypath
WARNING: Couldn't initialize pyplot. (might need to install it?)
INFO: To do a standard install of pyplot, copy and run this:

if !Plots.is_installed("PyPlot")
Pkg.add("PyPlot")
end
withenv("PYTHON" => "") do
Pkg.build("PyPlot")
end

now restart julia!

PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name))

Plots

Git
GitHub (preview)
Initialize this project directory with a git repository
Create repository

Looks like pyplot() is not installed properly.

Ok, so I restarted Julia and it works now! Thank you!

I am a beginner to using Julia and the IDE. So, jsut out of curiosity, why does "using PyPlots" prevent "pyplot"? Does it clash with "using Plots"?

Plots make use of the backends calling them in a different way than in their standalone versions.

Refer to the docs for further reference.

Ok, thank you!

I am not sure if I should open a new issue for this. If I wanted to plot a histogram:

https://gist.github.com/gizmaa/7214002#histogram

how can I visualize that?

I require "using PyPlot" for the histogram, but then if I use plot for any other figure in that code, it won't get displayed as now "plot" from "Plots" and "PyPlot" interfere with each other. (cause of my original issue).

x = randn(1000)
using Plots
histogram(x)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

SebastianM-C picture SebastianM-C  路  4Comments

pkofod picture pkofod  路  3Comments

kersulis picture kersulis  路  5Comments

tbenst picture tbenst  路  3Comments

asinghvi17 picture asinghvi17  路  3Comments