This example describes the Python drawing method. Share to everyone for your reference. Specific as follows:
#-*-Coding:utf-8-*-import Matplotlib.pyplot as Pltdef main (): # Color list colorlist = [' B ', ' G ', ' R ', ' C ', ' m ', ' y ', ' k ' ] # Common horizontal threadlist = [1,2,4,8,10] # Set the horizontal and ordinate names plt.xlabel (' Threads ') Plt.ylabel (' Concurrent ') # graph title plt.title (' Concurrent test ') # The list of lines to draw lines = [] # corresponds to the name of the line titles = [ ] # The ordinate of the first line dataList1 = [2,5,7,15,30] # draw the first line according to the horizontal axis and ordinate line1 = Plt.plot (threadlist, DataList1) # Set Line color width etc plt.setp (line1, color=colorlist[0], linewidth=2.0) # line name titles.append (' Linux ') lines.append (line1) # 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) #如果是pdf就, Plt.savefig ( '/home/workspace/test.pdf ') if __name__ = = ' __main__ ': Main ()
Hopefully this article will help you with Python programming.