1 First plots with matplotlibSimple drawing 1 Simple drawing 2 simple drawing 32 Grid = GRID3 Setting axis value range = Axis Xlim Ylim Method 1: Overall Setup [Xmin,xmax, ymin, ymax] = = = Plt.axis ([xmin, xmax, ymin, ymax]) Method 2: Set eachPlt.xlim ([xmin, Xmax])Plt.ylim ([ymin, Ymax])4 Set the coordinate meaning label = label5 Set the overall title of the picture = Title6 Set legend = Legend Method 2:plt.plot (x, x*1.5) plt.plot (x, x*3.0) plt.plot (x, x/3.0) plt.legend ([' Normal ', ' Fast ' , ' Slow ']) the position parameter of the legend: loc = Code
String |
Code |
Best |
0 |
Upper right |
1 |
Upper left |
2 |
Lower left |
3 |
Lower right |
4 |
Right |
5 |
Center left |
6 |
Center Right |
7 |
Lower Center |
8 |
Upper Center |
9 |
Center |
10 |
71 sub-complete image 8 Save picture = Savefig
ImportMatplotlib.pyplot as Pltplt.plot ([1, 2, 3]) Plt.savefig ("Plot123.png") Plt.savefig ('Plot123_2.png', dpi=200)#ImportMatplotlib as mplmpl.rcparams['figure.figsize']mpl.rcparams['savefig.dpi']mpl.reparams['Agg']
9 This summary all code examples
Import Matplotlib.pyplot as Pltplt.plot ([1, 3, 2, 4]) plt.show () import matplotlib.pyplot as Pltx = Range (6) Plt.plot (x, [xi* * * for XI in x]) plt.show () import Matplotlib.pyplot as Pltimport numpy as NPX = Np.arange (0.0, 6.0, 0.01) plt.plot (x, [x**2 For x in X]) plt.show () import Matplotlib.pyplot as Pltimport numpy as NPX = Np.arange (1, 5) plt.plot (x, x*1.5, X, x*3.0, X, x/3.0) Plt.grid (True) plt.show () import Matplotlib.pyplot as Pltimport numpy as NPX = Np.arange (1, 5) plt.plot (x, x*1.5, X, x* 3.0, X, x/3.0) Plt.axis () # shows the range of limit values for the current axis x-> (0.85, 4.15), y-> ( -0.25, 12.58) Plt.axis ([0, 5,-1, 13]) # New range of the current axis Plt.show () Import Matplotlib.pyplot as Pltplt.plot ([1, 3, 2, 4]) Plt.xlabel (' This was the X axis ') #这个是x轴的标签plt. Ylabel (' This is the Y axis ') #这个是y轴的标签plt. Show () Import Matplotlib.pyplot as Pltplt.plot ([1, 3, 2, 4]) Plt.title (' Simple plot ') # Image title P Lt.show () Import Matplotlib.pyplot as Pltimport numpy as NPX = Np.arange (1, 5) plt.plot (x, x*1.5, label= "Normal") Plt.plot (x , x*3.0, label= "Fast") plt.Plot (x, x/3.0, label= "Slow") Plt.legend () # set legend plt.show () import Matplotlib.pyplot as Pltimport numpy as NPX = Np.arange (1, 5) Plt.plot (x, x*1.5, X, x*3.0, X, x/3.0) Plt.grid (True) plt.title (' Sample growth of a Measure ') Plt.xlabel (' Samples ') Plt.ylabel (' Values measured ') plt.legend ([' Normal ', ' Fast ', ' Slow '], loc = ' upper Left ') plt.show () Import Matplotlib.pyplot as Pltplt.plot ([1, 2, 3]) plt.savefig ("Plot123.png") import matplotlib as mplmpl.rcparams[' Figure.figsize ']mpl.rcparams[' savefig.dpi ']plt.savefig (' plot123_2.png ', dpi=200)
Knowledge lies in a little bit of accumulation, I will be on this road go ahead,
lucky to see my blog friends, if you can learn knowledge, please pay more attention and discussion, let us progress together, set sail. PostScript: A piece of Limerick
Moderate exercise, quantitative indicators
Considering the weather, setting goals
Scientific exercise, achievement body Standard
Efficient scientific research to achieve learning standard
The matplotlib of Python3 drawing (01)