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 to bar3d
, documentation only tells me something about the appropriate format. I have found a few example on the internet, and also on stackoverflow, but these didn't help me to figure out which parameter contains which information.
Basically, this is my function:
bar3d(x, y, z, dx, dy, dz, color='b', zsort='average', *args, **kwargs)
I do not understand what x, y, z
and dx, dy, dz
do represent. Can anyone pls help me?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With