Hi how’s it going?
I want to make a 3d histogram, or a lego plot. What would be the best way of going about this?
For a hypothetical example, say x = [1,2,3,4,5], y = [0,5,30,10,15] and z = [50,100,150,200,250]
Here is a picture of what I’m looking for.
I see you are using ROOT, my how that brings back memories.
The Plots.jl package wraps lots of other plotting libraries, so I’d imagine there is this type of 2D (i.e. the distribution is 2D) histogram somewhere in there, but it might take a lot of digging through documentation to find it.
One thing that occurs to me is that you can make something like this using
surface in Makie. Of course, you’d need a separate histogram implementation to do that. There is one available in StatsBase.jl.
It doesn’t plot in 3D, but there’s
x = randn(1000)
y = randn(1000)
And while it isn’t quite the “Lego” effect, you can also fit a 2D histogram and plot it as a wireframe:
using StatsBase, Plots
h = fit(Histogram, (x, y), nbins=20)
plot(h) # same as histogram2d
wireframe(midpoints(h.edges), midpoints(h.edges), h.weights)
In case it wasn’t apparent, my suggestion was the same as @ElOceanografo’s,
surface in Makie is just an alternative that gives basically the same thing (I think makie has
wireframe as well).