How use Dataframes columns as a z axis for 3d plot

Hello,
I have a TimeArray in which the first column is the timestamp and all other columns are related to energy cost for a load over time. I have about 100 other columns. I’m trying to plot the other columns as a z axis, so I have something like: x_axis as TimeStamp, y_axis as values, z_axis as columns names/labels. I have named all data columns as [“c1”, “c2” etc].

Just don’t have idea if its possible or how to do this.

Anyone could help on this?

Thanks in advance!

DataFrame columns are just vectors. So nothing about DataFrames is needed here. Maybe this example in Plots.jl can help. Instead of x, y, and z, use the columns you want.


Hi, thanks for the answer. But I’m afraid its not what I’m looking for. Heatmap gave me the black graph on the right. I want something more like the left graph but in 3D and for all 121 columns.
In the left graph i showed only 5 of them.

You mean like this? https://www.r-graph-gallery.com/294-basic-ridgeline-plot.html

visualy this 3D graph would do the job! But not using the density function. Data I have isn’t a distribution or related. I tried for the last 2 days to draw this graph but its not working.

I’m trying to plot now with CairoMakie.jl Any other suggestion?

I don’t think I’ve ever seen one of those plots that aren’t a density plots, in R or Julia. The best option might be to abandon the ridge plot and just do a traditional line plot with different colors.

so I have something like: x_axis as TimeStamp, y_axis as values, z_axis as columns names/labels

Can you provide an example of your data? I’m not sure I understand what you are hoping to portray on the Z-Axis.

Would successive 3D line plots be adequate?
Plot3d_DataFrame

using Plots, Dates, DataFrames

dts = today():Year(1):today()+Year(20)
m = length(dts)
n = 100
vs = rand(m,n) .+ vec(1:n)' .- n÷2
df = DataFrame([dts vs], :auto)
p = plot(legend=false, xlabel="Date",ylabel="curve#",zlabel="values")
[plot!(df[:,1], fill(i,m), df[:,i+1]) for i in 1:n]
display(p)
1 Like

This code worked fine.

function plot_curvas_custo(custo::TimeArray)
	m = length(timestamp(custo))
	n = length(colnames(custo))
	df = values(custo)
	p = plot(legend=false, xlabel="Horário",ylabel="#Curva",zlabel="R\$")
	[plot!(timestamp(custo), fill(i,m), df[:,i]) for i in 1:div(n,10):n]
	plot(p)
end


Thanks to all that reply!!!

1 Like