Python Plotting Method example, python plotting example
This example describes the python plotting method. 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.