Python's drawing tools matplotlib use Instances _python

Source: Internet
Author: User
Tags explode

Matplotlib is a powerful Python module for drawing two-dimensional graphics, which uses the Python language to achieve the ease of use of the MATLAB drawing function, while having a very powerful customization capability. It provides a complete set of command APIs similar to MATLAB and is ideal for interactive mapping. It can also be conveniently embedded in GUI applications as a drawing control. Its documentation is fairly complete, and there are hundreds of thumbnails on the Gallery page, which are available after they are opened. So if you need to draw some kind of diagram, just browse, copy, paste it in this page, basically can be done!

The instance code is as follows:

1. Column Chart

Import Matplotlib.pyplot as Plt 
plt.bar (left = 0,height = 1)
plt.show ()

The operation effect is as follows:

2. Pie chart

#!  coding:cp936 from
pylab import * Make
a square figure and axes
figure (1, figsize= (6,6))
ax = axes ([0.1, 0.1, 0.8, 0.8]
fracs = [       #每一块占得比例], total for
explode= (0, 0, 0.08)       #离开整体的距离, see effect
labels = ' Hogs ', ' Dogs ', ' Logs ' #对应每一块的标志
pie (Fracs, Explode=explode, Labels=labels,
        autopct= '%1.1f%% ', shadow=true , startangle=90, colors = ("G", "R", "Y"))
                 # startangle is the starting angle, the default is 0, starting from here, expand the title in the counterclockwise direction
(' Raining hogs and Dogs ')  #标题 show
()

The operation effect is as follows:

Related Article

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.