matplotlib学习笔记6.盒图

import numpy as np
import matplotlib.pyplot as plt
# 不用打imshow也能显示
%matplotlib inline 

盒图

  • 基本盒图
x = [np.random.normal(0,std,100) for std in range(1,4)]
fig = plt.figure(figsize=(8,6))
# notch是否使用特别形状,sym离群点用什么表示,vert表示竖着画还是横着画
plt.boxplot(x,notch=False,sym='s',vert=True)
{'whiskers': [<matplotlib.lines.Line2D at 0x155fd3c0f60>,
  <matplotlib.lines.Line2D at 0x155fd3ca828>,
  <matplotlib.lines.Line2D at 0x155fd3d4f60>,
  <matplotlib.lines.Line2D at 0x155fd3d8748>,
  <matplotlib.lines.Line2D at 0x155fd3e4e80>,
  <matplotlib.lines.Line2D at 0x155fd3eb668>],
 'caps': [<matplotlib.lines.Line2D at 0x155fd3cac88>,
  <matplotlib.lines.Line2D at 0x155fd3cada0>,
  <matplotlib.lines.Line2D at 0x155fd3d8ba8>,
  <matplotlib.lines.Line2D at 0x155fd3d8cc0>,
  <matplotlib.lines.Line2D at 0x155fd3ebac8>,
  <matplotlib.lines.Line2D at 0x155fd3ebf28>],
 'boxes': [<matplotlib.lines.Line2D at 0x155fd3c0e10>,
  <matplotlib.lines.Line2D at 0x155fd3d4e48>,
  <matplotlib.lines.Line2D at 0x155fd3e4d68>],
 'medians': [<matplotlib.lines.Line2D at 0x155fd3d4588>,
  <matplotlib.lines.Line2D at 0x155fd3e44a8>,
  <matplotlib.lines.Line2D at 0x155fd3f23c8>],
 'fliers': [<matplotlib.lines.Line2D at 0x155fd3d49e8>,
  <matplotlib.lines.Line2D at 0x155fd3e4908>,
  <matplotlib.lines.Line2D at 0x155fd3f2828>],
 'means': []}

请添加图片描述

  • 细节
x = [np.random.normal(0,std,100) for std in range(1,4)]
fig = plt.figure(figsize=(8,6))
# notch是否使用特别形状,sym离群点用什么表示, patch_artist是否启用设置填充颜色
bplot = plt.boxplot(x,notch=False,sym='s',vert=True,patch_artist=False)

# 设置线条颜色
for components in bplot.keys():
    for line in bplot[components]:
        line.set_color('black')

请添加图片描述

x = [np.random.normal(0,std,100) for std in range(1,4)]
fig = plt.figure(figsize=(8,6))
# patch_artist是否启用设置填充颜色
bplot = plt.boxplot(x,notch=False,sym='s',vert=True,patch_artist=True)

# 设置填充颜色
for components in bplot['boxes']:
    components.set_color('lightblue')

请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值