# @df not defined

**URL:** <https://discourse.julialang.org/t/df-not-defined/44897>\
**Category:** General Usage\
**Tags:** question, plotting\
**Created:** [August 13, 2020, 9:23pm UTC](https://discourse.julialang.org/t/df-not-defined/44897 "2020-08-13T21:23:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [August 13, 2020, 9:23pm UTC](https://discourse.julialang.org/t/df-not-defined/44897/1 "2020-08-13T21:23:12Z")

</div>

Hiya, this is the example given by Plots.jl for plotting with dataframe ([Tutorial · Plots](https://docs.juliaplots.org/latest/tutorial/#Using-User-Recipes)). But everytime I tried, it reported ERROR:

`LoadError: UndefVarError: @df not defined`

Is there anything I missed causing this error?

```julia
using StatsPlots # Required for the DataFrame user recipe
## Now let's create the DataFrame
using DataFrames
df = DataFrame(a = 1:10, b = 10 * rand(10), c = 10 * rand(10))
## Plot the DataFrame by declaring the points by the column names
@df df plot(:a, [:b :c])

```

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [August 14, 2020, 12:49am UTC](https://discourse.julialang.org/t/df-not-defined/44897/2 "2020-08-14T00:49:25Z")

</div>

I do not use `Plots.jl` but appears to me that the documentation is for the `dev` version, unless you have cloned `master`, you may be using a package that is old enough to not have the macro you are calling. Which is your version of `Plots.jl`?

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [August 14, 2020, 1:23am UTC](https://discourse.julialang.org/t/df-not-defined/44897/3 "2020-08-14T01:23:52Z")

</div>

Works for me.

I suggest you start a new environment and try again

`] activate statsplots-test`  
`] add StatsPlots DataFrames`

`@df` is a macro defined in StatsPlots.jl

---

<div class="post-metadata">

**Author:** ![Dave.Shone](https://avatars.discourse-cdn.com/v4/letter/d/a698b9/32.png) [@Dave.Shone](https://discourse.julialang.org/u/Dave.Shone)\
**Post date:** [August 14, 2020, 2:13am UTC](https://discourse.julialang.org/t/df-not-defined/44897/4 "2020-08-14T02:13:10Z")

</div>

I ran into the same problem when (because I mistyped) I installed and used the deprecated StatPlots (instead of StatsPlots) then removed it and installed StatsPlots. Consequently, @df was exported by both StatPlots and StatsPlots. The fully-qualified macro name, @StatsPlots.df, worked at that stage, but restarting allowed @df to work properly.

Perhaps something similar happened for you?

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [August 14, 2020, 11:37am UTC](https://discourse.julialang.org/t/df-not-defined/44897/6 "2020-08-14T11:37:56Z")

</div>

Out of my expectation, after moving to new environment my old packages are still available. This is awesome.

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [August 14, 2020, 12:31pm UTC](https://discourse.julialang.org/t/df-not-defined/44897/7 "2020-08-14T12:31:42Z")

</div>

> [@1634](#):
>
> after moving to new environment my old packages are still available. This is awesome.

This shouldn’t happen, unless for example you initially installed things in the base environment (`@v1.5` for example). I would advise only putting things you use for development (Revise, Benchmark tools and the like) in the base environment - anything used in your actual project should be in that project’s Project.toml

---

<div class="post-metadata">

**Author:** ![sidpku](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sidpku/32/45729_2.png) [@sidpku](https://discourse.julialang.org/u/sidpku)\
**Post date:** [January 28, 2023, 5:52pm UTC](https://discourse.julialang.org/t/df-not-defined/44897/8 "2023-01-28T17:52:28Z")

</div>

maybe df is ambiguous.

@df refer to df(datafram)
