python basis of a library using Matplotlib (plan view)

  In our last few blog posts, when it comes to the use of Numpy, we can generate some data, let's take a look at how to make these data is presented on the picture, let us analyze the data more intuitive.

I will not repeat the installation process, not installed, go back Bubu most basic python knowledge.

  

We can see that we generated a set of X, we set up and y = 2x + 5, that is, we learn junior a linear equation.

plt.title ( "Matplotlib demo") set graphics (coordinates) name

plt.xlabel ( "x axis caption") Set the name of the X axis

plt.ylabel ( "y axis caption") set the name of the Y-axis, then we plt.plot (x, y) to transfer the picture we want to draw the x, yplt.show (), drawing output. So we get a simple line graph

Note that we generally use Matplotlib generally known plt, so we Freeze a name, and then use this right, easy to understand.

We then made to expand some of the lines, we have to enter the broken line, we can plt.plot (x, y, '-'), we have provided this red line, we can plt.plot (x, y, 'r--').

There are many parameters behind the set, you can log in directly to the official tutorial View https://www.matplotlib.org.cn/tutorials/advanced/index.html

x = np.arange(1,11) 
y =  2  * x +  5 
k = 3*x + 8
plt.title("Matplotlib demo") 
plt.xlabel("x axis caption") 
plt.ylabel("y axis caption") 
plt.plot(x,y,'--')
plt.plot(x,k)
plt.show()

我们也可以这样,同时画出多条线,还有很多高级的操作,饼状图,柱状图,我就不一一列举了。

Guess you like

Origin www.cnblogs.com/cxiaocai/p/11228738.html