Python + matplotlib: code for drawing a 3D bar chart instance, pythonmatplotlib
The example shared in this article mainly implements Python + matplotlib to draw a 3D bar chart with shadow and no shadow, as shown below.
First, let's take a look at the demo:
The complete code is as follows:
Import numpy as npimport matplotlib. pyplot as pltfrom mpl_toolkits.mplot3d import Axes3D # setup the figure and axesfig = plt. figure (figsize = (8, 3) ax1 = fig. add_subplot (121, projection = '3d ') ax2 = fig. add_subplot (122, projection = '3d ') # fake data_x = np. arange (4) _ y = np. arange (5) _ xx, _ yy = np. meshgrid (_ x, _ y) x, y = _ xx. ravel (), _ yy. ravel () top = x + ybottom = np. zeros_like (top) width = depth = 1ax1. bar3d (x, y, bottom, width, depth, top, shade = True) ax1.set _ title ('shaded') ax2.bar3d (x, y, bottom, width, depth, top, shade = False) ax2.set _ title ('not shaded') plt. show ()
Shade = True/False to make the shadow visible/invisible.
Summary
The above is all about the code for drawing 3D bar chart instances using python + matplotlib. I hope it will be helpful to you. If you are interested, you can continue to refer to other related topics on this site. If you have any shortcomings, please leave a message. Thank you for your support!