Python Plotting Method example

Source: Internet
Author: User

Python Plotting Method example

This example describes the python plotting method. Share it with you for your reference. The details are as follows:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

#-*-Coding: UTF-8 -*-

Import matplotlib. pyplot as plt

Def main ():

# Color list

ColorList = ['B', 'G', 'R', 'C', 'M', 'y', 'K']

# Shared abscissa

ThreadList = [1, 2, 4, 8, 10]

# Set the name of the horizontal and vertical coordinates

Plt. xlabel ('threads ')

Plt. ylabel ('concurrent ')

# Graph title

Plt. title ('current test ')

# List of lines to be drawn

Lines = []

# Line name

Titles = []

# Y coordinate of the first line

DataList1 = [2, 5, 7, 15, 30]

# Draw the first line based on the abscissa and ordinate

Line1 = plt. plot (threadList, dataList1)

# Set the color and width of the line

Plt. setp (line1, color = colorList [0], linewidth = 2.0)

# Line name

Titles. append ('linux ')

Lines. append (line1)

# Draw the second line in the same way

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 files, plt. savefig ('/home/workspace/testyun ')

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.