01 First knowledge of Python Matplotlib library

A first look at the Python Matplotlib library

Function name Instructions for use Instructions for use Instructions for use
title() Set icon name
xlabel() Set the name of the x-axis
ylabel() Set the name of the y-axis
xticks(x, ticks, rotation) Set the x-axis scale rotation is to set the scale rotation angle
xticks(y, ticks, rotation) Set the scale of the y-axis rotation is to set the rotation angle
plot() Draw a linear chart
show() Show chart
legend() Show legend
text(x, y, text) Display the value of each data, that is, the position of the x and y values
figure(name, figsize = (w, h), dpi = n) Set picture size

01 Draw basic graphics

plt.plot([1,4],[2,8],[3,10])
plt.show()
# 随机图形
a = []
for i in range(10):
    b = list(np.random.randint(i, i+5, 2))
    a.append(b)
print(a)    
plt.plot(a)
plt.show()
   
plt.plot([1,4],[2,8],[3,10])
plt.show()

Draw a line chart

a = np.arange(5)
print(a) # [0 1 2 3 4]
s = np.square(a)
print(s) # [ 0  1  4  9 16]
plt.plot(a,s)
plt.show()
Published 36 original articles · praised 0 · visits 631

Guess you like

Origin blog.csdn.net/Corollary/article/details/105382684