Python line graph based library module matplotlib

Details Reference

Python visualization library Matplotlib drawing entry Comments

python school that used

This morning saw the first chapter of this book, the book when it comes to how to use matplotlib to draw pictures, write books here put me in accordance with the code, knock again, and my understanding of this knowledge Talking point
man of few words said the Code

import matplotlib.pyplot as plt
import matplotlib as mpl
plt.plot([-2,2,3,4,5],label=u'第一条曲线')
plt.plot([3,4,5,8,9],label=u'第二条曲线')
plt.legend()
plt.grid(True)
plt.axis([0,5,-3,9])
plt.xlabel('X轴')
plt.ylabel('Y轴')
plt.title('matplotlib演示图')
plt.show()
plt.savefig('plot123.png')

Impression that this library is like the beginning of the numerical calculation using MATLAB course so much like, so to see Baidu, really similar.
1. First matplotlib need to import this module
2. plot () function creates two curves
designated x and Y
plt.plot (x, Y)
default parameters, x is-N. 1 ~ 0
plt.plot (Y)
3.legend () specifies the legend
4.grid () display grid
5.axis () the specified maximum and minimum coordinate axis
xlabel, ylabel, titile show the x and y axes and display the content title
6.show display image
7. save image

The results show

Here there is a problem because the Chinese show, so I put the code inside the Chinese into the English
Here Insert Picture Description
Finally, I hope to continue the follow-up can also understand the application of the library, insist on reading, learning python adhere to it!

Published 63 original articles · won praise 12 · views 4041

Guess you like

Origin blog.csdn.net/qq_45353823/article/details/104326491