I am working on a package which has both Plots and StatsPlots added. When using density from StatsPlots, even I use StatsPlots.density(blah), I got a warning twice for each density call:
┌ Warning: seriestype density has been moved to StatsPlots. To use: Pkg.add("StatsPlots"); using StatsPlots
└ @ Plots ~/.julia/packages/Plots/w4QRq/src/args.jl:1178
┌ Warning: seriestype density has been moved to StatsPlots. To use: Pkg.add("StatsPlots"); using StatsPlots
└ @ Plots ~/.julia/packages/Plots/w4QRq/src/args.jl:1178
The plot is working, but the warning is annoying. Any suggestion?
Why are you using both Plots and StatsPlots? StatsPlots is basically Plots with additional bells and whistles, so when you’re using StatsPlots you shouldn’t have to load Plots?
Hm, that’s odd. Can you just run the following in a fresh REPL?
julia> using StatsPlots
julia> density(rand(100))
(@v1.5) pkg> st StatsPlots
Status `~/.julia/environments/v1.5/Project.toml`
[f3b207a7] StatsPlots v0.14.17
I am using the same version of StatsPlots. Above gave no warning on my machine either.
I just found the problem. That is, I used Plots.measures somewhere. So, even I exclude Plots everywhere except Plots.Measures, I have the warnings. I don’t know how to circumvent those if am using .Measures.
Thanks a lot. I don’t know when and where I messed the codes in the project. The warnings came back into it again. As before, explicitly using StatsPlots.density won’t work either. Purely run you codes won’t give warnings. I will temporarily use Suppressor. Hope I can find the bug later.
I think, that the problem is in the following code !isdefined(Main, :StatsPlots) from Plots (v1.10.0 in args.jl:1178). It checks if the StatsPlots is loaded in the Main, so a warning will not appear if code is run directly from REPL
julia> using StatsPlots
julia> density()
However, if the StatsPlots is loaded in a different module (let say in module A), the warning will appear
julia> module A
using StatsPlots
end
Main.A
julia> using .A
julia> A.density()
┌ Warning: seriestype density has been moved to StatsPlots. To use: `Pkg.add("StatsPlots"); using StatsPlots`
└ @ Plots ~/.julia/packages/Plots/IjNHT/src/args.jl:1178
julia> isdefined(Main, :StatsPlots)
false
julia> isdefined(A, :StatsPlots)
true
The solution is to load StatsPlots in the Main module.