I want to make a 3d bar plot with python, and I discovered the bar3d
function. Here is the documentation.
I do not understand which values I have to pass over t
x
, y
, z
, dx
, dy
, dz
are iterators. They represent the x
and y
, z
positions of each bar and dx
, dy
, dz
represent the width, depth, and height (dimensions in x
, y
and z
) of the bars. Note that x
is the horizontal axis, y
is the depth axis, and z
is the vertical axis.
So 3 bars in a row with height of 5, 4 and 7 could be drawn like:
x = [1, 2, 3] # x coordinates of each bar
y = [0, 0, 0] # y coordinates of each bar
z = [0, 0, 0] # z coordinates of each bar
dx = [0.5, 0.5, 0.5] # Width of each bar
dy = [0.5, 0.5, 0.5] # Depth of each bar
dz = [5, 4, 7] # Height of each bar
All of them would have the same width and depth.
color
takes either a string that describes the color of all the bar, or a list of strings, if you want each bar with a different color.
I think zsort
has to do with how matplotlib is handling overlaps, but that is just a guess.