Python plotting tool matplotlib usage example

Source: Internet
Author: User

Matplotlib is a powerful Python module for drawing two-dimensional graphics. It uses the Python language to implement the ease-of-use of the MATLAB drawing function, and has very powerful customization. It provides a complete set of command APIs similar to matlab and is suitable for interactive plotting. It can also be easily used as a drawing control and embedded into GUI applications. Its documentation is quite complete, and there are hundreds of thumbnails on the Gallery page. After opening it, all the source programs are available. Therefore, if you want to draw a certain type of graph, you can simply browse, copy, and paste it on this page!

The instance code is as follows:

1. Bar Chart

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

The running effect is 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]) fracs = [45, 30, 25] # Percentage of each piece, total: 100 explode = (0, 0, 0.08) # Leave the overall distance, labels = 'hogs', 'dogs', and 'logs' # indicates the pie (fracs, explode = explode, labels = labels, autopct = '% 1.1f %', shadow = True, startangle = 90, colors = ("g", "r", "y") # startangle is the starting angle, the default value is 0. Start from here to expand title ('raining Hogs and Dogs ') # title show ()

The running 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.