Python's drawing tools Matplotlib use Instances

Source: Internet
Author: User
Matplotlib is a very powerful Python module for drawing two-dimensional graphics, it uses the Python language to achieve the ease of use of MATLAB drawing functions, but also has a very strong customizable. It provides a complete set of command APIs similar to those of MATLAB and is ideal for interactive mapping. It can also be easily used as a drawing control, embedded in GUI applications. Its documentation is quite complete, and there are hundreds of thumbnails on the gallery page, and the source program opens. So if you need to draw some kind of diagram, just browse, copy, paste it on this page and basically get it done!

The instance code is as follows:

1. Bar chart

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

The results are as follows:

2. Pie chart

#! Coding:cp936from Pylab Import *# make a square figure and axesfigure (1, figsize= (6,6)) ax = axes ([0.1, 0.1, 0.8, 0.8]) Frac s = [100explode=],       #每一块占得比例, sum of 0.08 (0, 0,       #离开整体的距离), see effect labels = ' hogs ', ' Dogs ', ' Logs ' #对应每一块的标志pie (fra CS, 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 in the counterclockwise direction to expand the title (' Raining Hogs and Dogs ')  #标题show ()

The results are as follows:

  • 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.