Matplotlib绘图线
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array([6, 2, 13, 10])
plt.plot(ypoints, linestyle = 'dotted')
plt.show()
Matplotlib 散点图
import matplotlib.pyplot as plt
import numpy as np
x = np.array([1, 2, 3, 4, 5, 6, 7, 8])
y = np.array([1, 4, 9, 16, 7, 11, 23, 18])
plt.scatter(x, y)
plt.show()
Matplotlib 柱形图
import matplotlib.pyplot as plt
import numpy as np
x = np.array(["Runoob-1", "Runoob-2", "Runoob-3", "C-RUNOOB"])
y = np.array([12, 22, 6, 18])
plt.bar(x,y)
plt.show()
Matplotlib 饼图
import matplotlib.pyplot as plt
import numpy as np
y = np.array([35, 25, 25, 15])
plt.pie(y,
labels=['A','B','C','D'], # 设置饼图标签
colors=["#d5695d", "#5d8ca8", "#65a479", "#a564c9"], # 设置饼图颜色
)
plt.title("RUNOOB Pie Test") # 设置标题
plt.show()