Python drawing curve (paper, report, etc.)

Source: Internet
Author: User
Tags install matplotlib

<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.)

Related Article

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.