Julia 1.3 中的 Plot:未定义 Plot 的函数

Plot in Julia 1.3: functions of Plot not defined

我正在尝试在 Julia 1.3 中构建散点图并找到了那些示例 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

我也试了一个官方的例子Plot documentaiton,但是得到了类似的错误信息:

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

我尝试用 using Pkg; Pkg.rm("Plots")using Pkg; Pkg.add("Plots") 删除并重新安装 Plots,但没有解决问题

Plots 的一些功能好像不是defined/found Julia

我做错了什么?

我不确定你为什么会遇到这个问题。我使用的是相同版本的 Julia,第一个示例对我有用。

你有添加后端吗? using Pkg; Pkg.add("GR");如果没有,就这样做。

您可以尝试重新启动您的机器,也许它处于异常状态。 打开 Julia REPL 并输入

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

您应该会看到 :scatter。如果这样做,请尝试散点图。如果不是,则说明您的配置存在问题。无论哪种情况,请让我们知道。

您可能需要指定函数的来源:

using Plots

Plots.scatter(...)