Python Plotting Method example

Source: Internet
Author: User
This article mainly introduces the python plotting method. The example analyzes the plotting skills of Python, and involves the usage of matplotlib module in Python. For more information, see the example in this article. Share it with you for your reference. The details are as follows:

#-*-Coding: UTF-8-*-import matplotlib. pyplot as pltdef main (): # color list colorList = ['B', 'G', 'R', 'C', 'M', 'y ', 'K'] # The common abscissa threadList = [1, 2, 4, 8, 10] # Set the name of the abscissa and the ordinate plt. xlabel ('threads') plt. ylabel ('concurrent') # title plt of the graph. title ('current test') # list of lines to be drawn lines = [] # corresponding line name titles = [] # dataList1 = [2, 5, 7, 15, 30] # draw the first line line1 = plt Based on the abscissa and ordinate. plot (threadList, dataList1) # Set the color width and other plt of the line. setp (line1, color = colorList [0], linewidth = 2.0) # line name titles. append ('linux ') lines. append (line1) # similarly draw the second line dataList2 = [2, 4, 6, 18, 35] line2 = plt. plot (threadList, dataList2) plt. setp (line2, color = colorList [1], linewidth = 2.0) titles. append ('freebsd ') lines. append (line2) plt. legend (lines, titles) plt. savefig ('/home/workspace/test.png', dpi = 120) # for pdf, plt. savefig ('/home/workspace/testbench') if _ name _ = '_ main _': main ()

I hope this article will help you with Python programming.

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.