3d histogram plot with PGFPlotsX and StatsBase

Hi,

I would like to do something similiar like this

with PGFPlotsX. I´m a newbie in plotting with PGFPlotsX. I tried to it analogously like the example.

I use StatsBase for plotting the histogram.

Here first the code of a 2d histogram.

using Random
using Distributions
using PGFPlotsX
using Plots
plotly()
using StatsBase: fit
using StatsBase: Histogram


dists = [randn(1000, 1) for i in 1:4]

# create axis
axis = @pgf Axis(
    {
        grid = "both",
        xmax = maximum(dists[1]),
        xmin = minimum(dists[1]),
        xlabel="x",
        ylabel="y",
        xtick = collect(round(minimum([minimum(dists[i])  for i in 1:length(dists)]), digits=1):0.5:round(maximum([maximum(dists[i])  for i in 1:length(dists)]), digits=1)),
        ytick = collect(0:20:100),
        xticklabel = raw"$\pgfmathprintnumber\tick$",
        "xticklabel style" =
        {
            "rotate"=90,
            "anchor"="east",
            font = raw"\tiny"
        },
    },
)


# draw histogram
hist1 = @pgf Plot(
    {
    fill_opacity = 0.65,
    color = "blue",
    fill = "blue",
    "ybar interval"
    },
    Table(fit(Histogram, vec(dists[1]), closed = :left, nbins=40)))

push!(axis, hist1)

# draw red line
line = @pgf Plot(
        {
            color = "red",
            style ="{dashed}"
        },
        Coordinates(
            [
                (0.25, 0),
                (0.25, 100),

            ]
        )
)
push!(axis, line)

#save plot
path = (@__DIR__) * raw"\histogram.tex"
pgfsave(path, axis, include_preamble=true, dpi=150)

When I would like to plot it in a 3d graph, then I think, that I´ve to extract the values of the histogram for my x- and y-axis of the Table in the 3d plot to plot it analogously like the 3d waterfall example .

curve = Plot3(
            {
                no_marks,
                style = {thick},
                color = "blue"
            },
#######################################
            Table(x = x_pnts,
                  y = (length(dists) - i) * ones(length(x_pnts)),
                  z = dat_pdf[i](x_pnts))
#######################################
        )

Does somebody know how to do it or has an alternative?

I don’t have time to work out an example now, but I am not 100% sure that pgfplots histograms also work in 3D, so that would be the first thing to check. Generally, it is best to look up the solution using LaTeX, and convert it to PGFPlotsX then.

I think, this is true. I found several attempts to find a workaround for a 3D histogram in pgfplots, so I guess they are just made, because pgfplots hasn´t it right away