散点图
scatter
只标点,不画图
import matplotlib.pyplot as plt
import numpy as np
x=range(10)
y=np.random.randn(10)#产生随机值
plt.scatter(x,y,color='r',marker='*')#marker为设置标点的样式
plt.show()
条形图
垂直条形图
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(5)
y = np.random.randn(5)
ax1=plt.bar(x,y,color='b',)#bar用于绘制垂直条形图
plt.grid(0.5)
plt.show()
水平条形图
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(5)
y = np.random.randn(5)
ax2=plt.barh(x,y,color='r')
plt.grid(0.5)
plt.show()
饼图
pie
import matplotlib.pyplot as plt
import numpy as np
labels='a','b','c','d','e'
sizes=[10,25,25,5,35]
plt.pie(sizes,labels=labels,autopct='%1.1f%%')#pie用于绘制饼图 autopct用于设置显示占比
plt.legend()
plt.show()