StatsPlots出图失败

windows

using Pkg
Pkg.add("JuliaDB")
Pkg.add("StatsPlots")

using JuliaDB
using StatsPlots

t = table((x = randn(10), y = randn(10)))
println(t)

@df t scatter(:x, :y)

报错信息:

ERROR: LoadError: MethodError: no method matching get_color_palette(::Symbol, ::RGBA{Float64}, ::Int64)
Closest candidates are:
get_color_palette(::Any, ::Any) at C:\Users\ping.zhou.julia\packages\PlotUtils\nCtbM\src\colorschemes.jl:328
get_color_palette(::ColorGradient, ::Any) at C:\Users\ping.zhou.julia\packages\PlotUtils\nCtbM\src\colorschemes.jl:329
Stacktrace:
[1] _update_subplot_colors(::Plots.Subplot{Plots.GRBackend}) at C:\Users\ping.zhou.julia\packages\Plots\WwFyB\src\args.jl:1436
[2] _update_subplot_args(::Plots.Plot{Plots.GRBackend}, ::Plots.Subplot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Int64, ::Bool) at C:\Users\ping.zhou.julia\packages\Plots\WwFyB\src\args.jl:1523
[3] _subplot_setup(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Array{Dict{Symbol,Any},1}) at C:\Users\ping.zhou.julia\packages\Plots\WwFyB\src\pipeline.jl:297
[4] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Float64,1},Array{Float64,1}}) at C:\Users\ping.zhou.julia\packages\Plots\WwFyB\src\plot.jl:206
[5] plot(::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N; kw::Base.Iterators.Pairs{Symbol,Symbol,Tuple{Symbol},NamedTuple{(:seriestype,),Tuple{Symbol}}}) at C:\Users\ping.zhou.julia\packages\Plots\WwFyB\src\plot.jl:57
[6] scatter(::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N; kw::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\ping.zhou.julia\packages\RecipesBase\zBoFG\src\RecipesBase.jl:369
[7] scatter(::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at C:\Users\ping.zhou.julia\packages\RecipesBase\zBoFG\src\RecipesBase.jl:369
[8] add_label(::Array{String,1}, ::Function, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at C:\Users\ping.zhou.julia\packages\StatsPlots\Y1rGZ\src\df.jl:139
[9] add_label(::Array{String,1}, ::Function, ::Array{Float64,1}, ::Vararg{Array{Float64,1},N} where N) at C:\Users\ping.zhou.julia\packages\StatsPlots\Y1rGZ\src\df.jl:137
[10] (::var"#1#2")(::IndexedTable{StructArrays.StructArray{NamedTuple{(:x, :y),Tuple{Float64,Float64}},1,NamedTuple{(:x, :y),Tuple{Array{Float64,1},Array{Float64,1}}},Int64}}) at .\none:0
[11] top-level scope at C:\Users\ping.zhou\Desktop\julia_code\test.jl:19
[12] include(::Function, ::Module, ::String) at .\Base.jl:380
[13] include(::Module, ::String) at .\Base.jl:368
[14] exec_options(::Base.JLOptions) at .\client.jl:296
[15] _start() at .\client.jl:506
in expression starting at C:\Users\ping.zhou\Desktop\julia_code\test.jl:19

https://cleytonfar.github.io/posts/using-julia-for-data-science-part-03/

这个示例也是报同样的错

会不会是你的GR后端没开啊,试试

using GR
gr()

应该和gr没关系
我是参考的这个
https://juliadata.github.io/JuliaDB.jl/stable/plotting/#StatsPlots-1

JuliaDB has all access to all the power and flexibility of Plots via StatsPlots and the @df macro.

其实就是用了 Plots.jl ,先确保你有一个能用的后端。

StatsPlots已经安装好了的,
看提示是没找到调用的函数

环境没有安装好,全部卸载,重来就好了