1
votes

I'm trying to build a scatter plot in Julia 1.3 and found those example there

using Plots
scatter( 1:16, sqrt.(1:16), labels="Square Root", size=[600,240] )

ERROR: LoadError: UndefVarError: scatter not defined
Stacktrace:
 [1] top-level scope at /Users/...:19
 [2] include at ./boot.jl:328 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1105
 [4] include(::Module, ::String) at ./Base.jl:31
 [5] include(::String) at ./client.jl:424
 [6] top-level scope at REPL[22]:1
in expression starting at /Users/...:19

I also tried an example from the official Plot documentaiton, but got a similar error message:

using Plots
l = @layout [  a{0.3w} [grid(3,3)
                         b{0.2h} ]]
plot(
    rand(10,11),
    layout = l, legend = false, seriestype = [:bar :scatter :path],
    title = ["($i)" for j = 1:1, i=1:11], titleloc = :right, titlefont = fo
)

ERROR: LoadError: UndefVarError: grid not defined
Stacktrace:
 [1] top-level scope at /Users/mymac/.julia/packages/Plots/2KhB2/src/layouts.jl:671
 [2] include at ./boot.jl:328 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1105
 [4] include(::Module, ::String) at ./Base.jl:31
 [5] include(::String) at ./client.jl:424
 [6] top-level scope at REPL[22]:1
in expression starting at /Users/...:10

I tried to remove and re-install Plots with using Pkg; Pkg.rm("Plots") and using Pkg; Pkg.add("Plots"), but it didn't solve the problem

It seems that some of the functions of Plots are not defined/found by Julia

What am I doing wrong?

2
What you are doing is correct. There must be some very weird issue with the code when it was downloaded. I would try potentially removing your Julia 1.3 project and manifest file and starting clean. It may also be worth trying to do a rm Plots build resolve up and such just to try and clean out any weirdness that is causing this issue.logankilpatrick

2 Answers

2
votes

I am not sure why you are having that problem. I am using the same version of Julia, and the first example worked for me.scatterplot screen

Have you added a backend? using Pkg; Pkg.add("GR"); If not, do so.

You might try restarting your machine, perhaps it is in an odd state. Open the Julia REPL and type

julia> using Plots
julia> names(Plots)[251]

You should see :scatter. If you do, then try the scatter plot. If not, there is an issue with your configuration. Let us know in either case.

1
votes

You may need to specify where the function came from:

using Plots

Plots.scatter(...)