<pre name= "code" class= "Python" > in many cases, such as writing a paper, such as writing a report, such as PPT, need to spend a lot of a lot of graphs, convincing others that data visualization is human instinct. If the reader you are unfortunate, like I do not use MATLAB and other things to draw or do not use MATLAB to draw, then a little attention to Python, because Python has a very powerful library matplotlib, Let the user directly with terminal can do most of the MATLAB drawing can do things. Matplotlib installation, you can install PIP then sudo pip install matplotlib If, now the task is to read the data from three text documents, then draw a graph and then compare, then you can do the following code as follows:
<pre name= "code" class= "python" >#!/usr/bin/env pythonimport Pylab as Plimport numpy as Npfilename1 = ' NUMBERCUTOUT0 ' filename2 = ' NUMBERCUTOUT1 ' filename3 = ' NUMBERCUTOUT2 ' file1 = open (filename1, ' r ') file2 = open (filename2, ' r ') File3 = Open (Filename3, ' r ') value1 = []value2 = []VALUE3 = []for word in File1:value1.append (word[:-1]) for word in File2:value2.app End (Word[:-1]) for word in File3:value3.append (word[:-1]) length = Len (value1) X = Np.linspace (0,length,length,endpoint= True) FIG = pl.figure (1) pl.plot (x,value1, color = ' Blue ', LineWidth = 1.0, LineStyle = ': ', label= ' Straight-forward Structure ') pl.plot (x,value2, color = ' green ', linewidth=1.0, linestyle= '-', label= ' single-branch Structure ') Pl.plot (X , value3, color = ' red ', linewidth=1.0, linestyle= '--', label= ' double-branch Structure ') pl.legend (loc= ' upper right ') Pl.title (' Singlebranch (Blue) doublebranch (Green) triblebranch (Red) ') pl.show ()
Python drawing curve (paper, report, etc.)