# Warning: when using both Plots and StatsPlots

**URL:** <https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118>\
**Category:** Visualization\
**Tags:** plotting\
**Created:** [November 13, 2020, 11:19pm UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118 "2020-11-13T23:19:08Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xijiang\_Yu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xijiang_yu/32/14439_2.png) [@Xijiang\_Yu](https://discourse.julialang.org/u/Xijiang_Yu)\
**Post date:** [November 13, 2020, 11:19pm UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/1 "2020-11-13T23:19:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [November 14, 2020, 7:05am UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/2 "2020-11-14T07:05:38Z")

</div>

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`?

---

<div class="post-metadata">

**Author:** ![Xijiang\_Yu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xijiang_yu/32/14439_2.png) [@Xijiang\_Yu](https://discourse.julialang.org/u/Xijiang_Yu)\
**Post date:** [November 14, 2020, 10:35am UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/3 "2020-11-14T10:35:58Z")

</div>

I removed `Plots`, the warnings still stick.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [November 15, 2020, 9:17am UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/4 "2020-11-15T09:17:25Z")

</div>

Hm, that’s odd. Can you just run the following in a fresh REPL?

```julia
julia> using StatsPlots

julia> density(rand(100))

(@v1.5) pkg> st StatsPlots
Status `~/.julia/environments/v1.5/Project.toml`
  [f3b207a7] StatsPlots v0.14.17

```

This works for me without warning

---

<div class="post-metadata">

**Author:** ![Xijiang\_Yu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xijiang_yu/32/14439_2.png) [@Xijiang\_Yu](https://discourse.julialang.org/u/Xijiang_Yu)\
**Post date:** [November 16, 2020, 10:07am UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/5 "2020-11-16T10:07:49Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [November 16, 2020, 11:47am UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/6 "2020-11-16T11:47:16Z")

</div>

Hm, could you post an MWE? When I do

```julia
julia> using StatsPlots

julia> Plots.Measures
Measures

julia> density(rand(100), margin = 5Plots.mm)

```

I still don’t get the warning.

Two other options:

- Try explicitly qualifying `StatsPlots.density`
- Use [Suppressor.jl](https://github.com/JuliaIO/Suppressor.jl) to suppress the warning

---

<div class="post-metadata">

**Author:** ![Xijiang\_Yu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xijiang_yu/32/14439_2.png) [@Xijiang\_Yu](https://discourse.julialang.org/u/Xijiang_Yu)\
**Post date:** [November 16, 2020, 2:34pm UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/7 "2020-11-16T14:34:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![VaclavMacha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vaclavmacha/32/20825_2.png) [@VaclavMacha](https://discourse.julialang.org/u/VaclavMacha)\
**Post date:** [January 6, 2021, 9:28pm UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/8 "2021-01-06T21:28:19Z")

</div>

I think, that the problem is in the following code `!isdefined(Main, :StatsPlots)` from Plots ([v1.10.0 in args.jl:1178](https://github.com/JuliaPlots/Plots.jl/blob/v1.10.0/src/args.jl)). It checks if the StatsPlots is loaded in the `Main`, so a warning will not appear if code is run directly from REPL

```julia
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
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.

---

<div class="post-metadata">

**Author:** ![bicepjai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bicepjai/32/18158_2.png) [@bicepjai](https://discourse.julialang.org/u/bicepjai)\
**Post date:** [April 28, 2022, 5:50pm UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/9 "2022-04-28T17:50:32Z")

</div>

This is happening in pluto notebooks and can you help suppress them ?  
using [Suppressor.jl](https://github.com/JuliaIO/Suppressor.jl) did not work.

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [April 28, 2022, 6:35pm UTC](https://discourse.julialang.org/t/warning-when-using-both-plots-and-statsplots/50118/10 "2022-04-28T18:35:10Z")

</div>

That was fixed in recent versions of Plots
