简体   繁体   中英

How to fill mplot3d bar plot depth? [Python 3.x]

There is an example for how to build a bar plot at the bottom of this question taken from the matplotlib site.

I cannot find a parameter to increase the depth of each bar. I want depth to give it a 3d look like this picture.

Is there a function parameter to change this that I'm not seeing, or will I need to use a different 3D bar plot function?

Below is the bar plot code from the first link in case someone can't see it:

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]):
    xs = np.arange(20)
    ys = np.random.rand(20)

    # You can provide either a single color or an array. To demonstrate this,
    # the first bar of each set will be colored cyan.
    cs = [c] * len(xs)
    cs[0] = 'c'
    ax.bar(xs, ys, zs=z, zdir='y', color=cs, alpha=0.8)

ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')

plt.show()

I've found this link to a solution but this solution doesn't actually increase the depth. I'm hoping for a method to completely fill the depth if possible.

Do you want something like the code in this answer ? They use bar3d() , but the locations for each bar are manually created with meshgrid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM