python - 箱线图不显示异常值
问题描述
这是我创建箱线图的功能。但它没有显示异常值。有什么帮助吗?
def box_plot_draw (data, box_colors):
#plt.style.use('Solarize_Light2')
fig, ax = plt.subplots()#figsize=(10, 6))
fig.canvas.set_window_title('A Boxplot Example')
fig.subplots_adjust(left=0.075, right=0.95, top=0.9, bottom=0.25) #
bp = ax.boxplot(data, notch=0, sym='+', vert=1, whis=1.5)
plt.setp(bp['boxes'], color='black')
plt.setp(bp['whiskers'], color='black')
plt.setp(bp['fliers'], color='red', marker='+')
box_colors = box_colors
ax.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5) #what is which?
ax.set_axisbelow(True)
#setting the tile for distribution
ax.set_title('Comparison of the duration of time for two Distributions')
ax.set_xlabel('Distribution')
ax.set_ylabel('Value')
您可以使用此数据测试代码。
np.random.seed(10)
collectn_1 = np.random.normal(100, 10, 200)
collectn_2 = np.random.normal(80, 30, 200)
## combine these different collections into a list
data_to_plot = [collectn_1, collectn_2]
box_colors = ['black', 'green']
box_plot_draw (data_to_plot, box_colors)
plt.show()
我正在使用 Jupyter 笔记本,并将样式用于其他功能。但是我没有为这个功能使用任何样式。
解决方案
推荐阅读
- python - 从 s3 读取一个 csv 文件,不包括一些值
- apache-camel - 基于表达式处理的事务性 Camel 路由标记交换不起作用
- .net - 升级到 .NET 5 后生成服务器上的 MSB3644
- python - 修补时如何引用本地导入-正确的python测试结构
- firebase - Firebase:通过存储在正文中的 ID 更新文档
- amazon-web-services - Terraform 计划在导入 aws 资源后显示差异
- powershell - Windows Sandbox PowerShell 登录命令窗口不可见
- unity3d - 聚光灯不适用于统一 Urp 中的虚拟现实
- kubernetes - 在 Kubernetes 集群中运行 boinc 客户端
- python - 匹配来自两个单独列表的单词