# Plot every columns of a DataFrame

**URL:** <https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808>\
**Category:** General Usage\
**Tags:** dataframes, plots\
**Created:** [December 30, 2025, 4:59pm UTC](https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808 "2025-12-30T16:59:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ju\_ska](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Post date:** [December 30, 2025, 4:59pm UTC](https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808/1 "2025-12-30T16:59:06Z")

</div>

Hi,

I would like to stack plots on top of each other without having to manage columns.  
Like separating the x axis from every other columns, then plot.

```julia-auto
using DataFrames
using Plots

df = DataFrame(x = [1,2,3,4], y1 = [8,9,9,8], y2=[3,5,3,3])

```

Without success, I tried things like:

```julia-auto
extract = df[:, filter(x -> x != ["x"], names(df))]
plot(df.x, eachcol(extract), layout = (2, 1))

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 30, 2025, 5:24pm UTC](https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808/2 "2025-12-30T17:24:07Z")

</div>

Using StatsPlots.jl with DataFrames.jl is a good combo:

```julia-auto
using DataFrames, StatsPlots

df = DataFrame(x = [1,2,3,4], y1 = [8,9,9,8], y2=[3,5,3,3])

ys = Symbol.(names(df, Not(:x)))
@df df plot(:x, cols(ys); layout=(2,1))

```

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [December 30, 2025, 8:31pm UTC](https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808/3 "2025-12-30T20:31:08Z")

</div>

> [@Ju\_ska](#):
>
> Without success, I tried things like:

```julia-auto
julia> plot(df.x, eachcol(extract), layout = (2, 1))
ERROR: Cannot convert DataFrames.DataFrameColumns{DataFrame} to series data for plotting

```

try this

```julia-auto

extract = df[:, filter(x -> x != "x" , names(df))]
plot(df.x, collect(eachcol(extract)), layout = (2, 1))

```

or this

```julia-auto
plot(df.x, [eachcol(extract)...], layout = (2, 1))

```

```julia-auto
p=plot();
for c in eachcol(extract)
    plot!(df.x, c)
end 
display(p)

```

---

<div class="post-metadata">

**Author:** ![Ju\_ska](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Ju\_ska](https://discourse.julialang.org/u/Ju_ska)\
**Post date:** [January 7, 2026, 12:05pm UTC](https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808/4 "2026-01-07T12:05:35Z")

</div>

Thanks everyone !

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 7, 2026, 6:27pm UTC](https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808/5 "2026-01-07T18:27:06Z")

</div>

We don’t need to extract a new dataframe for this. We can just take the names of the columns (and also use these in the legends):

```julia-auto
colnames = filter(!=("x"), names(df))
plot(df.x, getproperty.(Ref(df), colnames), labels=permutedims(colnames), layout=(ncol(df)-1,1))

```

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [January 7, 2026, 6:58pm UTC](https://discourse.julialang.org/t/plot-every-columns-of-a-dataframe/134808/6 "2026-01-07T18:58:41Z")

</div>

Just want to point out that `names(df)` supports a `Not` argument

```julia-auto
julia> using DataFrames

julia> df = DataFrame(x = 1, y = 2, z = 3);

julia> names(df, Not("x"))
2-element Vector{String}:
 "y"
 "z"

```
