#-*-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 () |