Python + matplotlib: code for drawing a 3D bar chart instance, pythonmatplotlib

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.