Ju_ska
1
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.
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:
extract = df[:, filter(x -> x != ["x" ], names(df))]
plot(df.x, eachcol(extract), layout = (2, 1))
Using StatsPlots.jl with DataFrames.jl is a good combo:
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), label=true, ylims=(0,12))
julia> plot(df.x, eachcol(extract), layout = (2, 1))
ERROR: Cannot convert DataFrames.DataFrameColumns{DataFrame} to series data for plotting
try this
extract = df[:, filter(x -> x != "x" , names(df))]
plot(df.x, collect(eachcol(extract)), layout = (2, 1))
or this
plot(df.x, [eachcol(extract)...], layout = (2, 1))
p=plot();
for c in eachcol(extract)
plot!(df.x, c)
end
display(p)