水平条形图 barh
-
方法:
barh(y, width, height=0.8, left=None, *, align=‘center’, **kwargs) -
参数:
- y:表示柱子所处的y坐标
- width:柱子的宽度,即x轴坐标
- height:柱子的高度,默认0.8
- align:表示柱子的对齐方式。可选{‘center’, ‘edge’},默认’center’。
- color:柱子的颜色
- edgecolor:表示柱子边框的颜色
-
实例:
x = np.arange(6)
y = np.arange(6)
z = np.arange(1,7)
plt.barh(x,y*2)
plt.ylim(0)
面积图 stackplot
-
方法:
stackplot(x, *args, labels=(), colors=None, baseline=‘zero’, data=None, **kwargs) -
参数:
- x:x轴坐标
- y:y轴坐标,可以是:stackplot(x, y1, y2, y3, y4)
- baseline:基线计算方法。可选:{‘zero’, ‘sym’, ‘wiggle’, ‘weighted_wiggle’}
-
实例:
x = ['第一季度','第二季度','第三季度','第四季度']
y1 = [120,150,168,170]
y2 = [90,142,190,136]
plt.stackplot(x,y1,y2,baseline='zero',labels=['北京','上海'])
plt.xlabel('季度')
plt.ylabel('销量')
plt.title('北京-上海季度销量')
plt.legend(loc='upper left')
雷达图 polar
-
方法:
stackploplt.polar(theta, r, color, marker, linewidth)
-
参数:
- theta:在极坐标中的角度
- r:半径长度
- marker:标记
- linewidth:连接线的宽度
-
实例:
theta = np.linspace(0,2*np.pi,num=5,endpoint=False)
data = [5,1,4,4,3]
theta = np.concatenate((theta,[theta[0]]))
data = np.concatenate((data,[data[0]]))
plt.polar(theta,data)
plt.xticks(theta,['服务','时长','业绩','年限','成绩'])
箱体图 boxplot
- 方法:
boxplot(x, notch=None, sym=None, vert=None, whis=None, positions=None, widths=None, patch_artist=None, bootstrap=None, usermedians=None, conf_intervals=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None, manage_ticks=True, autorange=False, zorder=None, *, data=None) - 参数:
- x:待绘制数据
- vert:箱体方向,True:纵向,False:横向
- widths:箱体宽度
- labels:标签
- 实例:
y1 = 10+2.5*np.random.randn(500)
y2 = 8+1.5*np.random.randn(500)
plt.boxplot([y1,y2],vert=True,widths=0.2,labels=['y1','y2'])