Error using plot function

I am new to Julia. I am using a 64 bit Windows 7 OS. Julia Version is 1.5.2. I installed the Plots package but I cannot use the plot function.

using Plots
x = 1:10; y = rand(10, 2)
plot(x, y)

I am getting this error.

UndefVarError: plot not defined

Stacktrace:
[1] top-level scope at In[29]:2
[2] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
[3] execute_code(::String, ::String) at C:\Users\Administrator.julia\packages\IJulia\rWZ9e\src\execute_request.jl:27
[4] execute_request(::ZMQ.Socket, ::IJulia.Msg) at C:\Users\Administrator.julia\packages\IJulia\rWZ9e\src\execute_request.jl:86
[5] #invokelatest#1 at .\essentials.jl:710 [inlined]
[6] invokelatest at .\essentials.jl:709 [inlined]
[7] eventloop(::ZMQ.Socket) at C:\Users\Administrator.julia\packages\IJulia\rWZ9e\src\eventloop.jl:8
[8] (::IJulia.var"#15#18")() at .\task.jl:356

using Plots should import the plot function, after which you can not get that error. So that is where things go wrong at least; the Plots package is not properly loaded into your workspace

now I am getting this
ArgumentError: Package Plots [91a5bcdd-55d7-5caf-9e0b-520d859cae80] is required but does not seem to be installed:

  • Run Pkg.instantiate() to install all recorded dependencies.

Stacktrace:
[1] _require(::Base.PkgId) at .\loading.jl:999
[2] require(::Base.PkgId) at .\loading.jl:928
[3] require(::Module, ::Symbol) at .\loading.jl:923
[4] include_string(::Function, ::Module, ::String, ::String) at .\loading.jl:1091
[5] execute_code(::String, ::String) at C:\Users\Administrator.julia\packages\IJulia\rWZ9e\src\execute_request.jl:27
[6] execute_request(::ZMQ.Socket, ::IJulia.Msg) at C:\Users\Administrator.julia\packages\IJulia\rWZ9e\src\execute_request.jl:86
[7] #invokelatest#1 at .\essentials.jl:710 [inlined]
[8] invokelatest at .\essentials.jl:709 [inlined]
[9] eventloop(::ZMQ.Socket) at C:\Users\Administrator.julia\packages\IJulia\rWZ9e\src\eventloop.jl:8
[10] (::IJulia.var"#15#18")() at .\task.jl:356

Then I would reccomend doing what it says - it is generally a good idea. Make sure to run using Pkg first, so that you can use the function with the suggested command

it still did not solve the problem

What happens when you start a fresh Julia session and type:

julia> using Plots

julia> plot(rand(10))

?

It is working now. thanks

1 Like