matplotlib bar3d

Solutions on MaxInterview for matplotlib bar3d by the best coders in the world

showing results for - "matplotlib bar3d"
Leonie
29 Jul 2017
1import numpy as np
2import matplotlib.pyplot as plt
3
4
5# setup the figure and axes
6fig = plt.figure(figsize=(8, 3))
7ax1 = fig.add_subplot(121, projection='3d')
8ax2 = fig.add_subplot(122, projection='3d')
9
10# fake data
11_x = np.arange(4)
12_y = np.arange(5)
13_xx, _yy = np.meshgrid(_x, _y)
14x, y = _xx.ravel(), _yy.ravel()
15
16top = x + y
17bottom = np.zeros_like(top)
18width = depth = 1
19
20ax1.bar3d(x, y, bottom, width, depth, top, shade=True)
21ax1.set_title('Shaded')
22
23ax2.bar3d(x, y, bottom, width, depth, top, shade=False)
24ax2.set_title('Not Shaded')
25
26plt.show()
27