Plotly does not provide a 3d bar chart, but you can define it yourself as follows(I summarize here how I did it in Python):
Define the vertices of the unit cube as an array of elements:
[[0, 0, 0],
[1, 0, 0],
[1, 1, 0],
[0, 1, 0],
[0, 0, 1],
[1, 0, 1],
[1, 1, 1],
[0, 1, 1]]
-
find the
xmin, xmax ymin ymax
of your 2d data -
fix a number of bins in the x, respectively y direction (depending on
xmin, xmax, ymin, ymax
) -
define a 3d bar chart with an appropriate function in R that can return the height of each bar and
xedges, yedges (I called this numpy funtion: https://docs.scipy.org/doc/numpy/reference/generated/numpy.histogram.html) -
from the data returned by the above function set up an array that holds the 3d position of each 3d bar, i.e. the positions
in the xOz plane, of z coordinate, z=0, where the above template cube is to be translated. -
each bar has three numerical caracteristics:
xsize = xedges[1]-xedges[0]-bargap
ysize = yedges[1]-yedges[0]-bargap
height (returned by an appropriate R function)
My bargap was set to 0.05
To get the vertices of each 3d bar, rescale the template cube to get a parallelepiped of dimensions (xsize, ysize, height) and then
translate it (move it) to the corresponding position mentioned above.
Triangulate each such a parallelepiped extracting its vertices and triangular faces.
With a proper R function extract a list of unique vertices and corresponding triangular faces
that define a Plotly Mesh3d.
Here is my Python code https://plot.ly/~empet/15255 and this is a such 3d
bar chart: