我想知道是否有可能把70%的人口放在盒子里,就像红色的盒子里一样? 我知道Q3-Q1=IQR,但不知道这对我有什么帮助. 我正在使用matplotlib绘制我的框图.

boxplot_50_70

def boxplot_one_micro_competence(one_micro):
     """
     show the boxplot corresponding to the list in parameters
     --------
     Parameters :
     one_micro - list - list of questions_id for the micro desired 
     --------
     >>> boxplot_one_micro_competence(sere)
     """    
     plt.subplots(figsize=(4, 4))
     plt.boxplot(df_micro_competence_groupe(one_micro)['score'], showcaps = False, whis = False, showfliers = False, labels = [one_micro])

     plt.ylim(-0.1, 4.1)
     plt.show()

boxplot_one_micro_competence(sere)

result

目前,我的代码看起来是这样的.

任何帮助我们都将不胜感激!

如果我的解释不够清楚,请让我知道;)

谢谢!

推荐答案

我引用了this solution作为参考:

import matplotlib.cbook as cbook
import matplotlib.pyplot as plt
import numpy as np

# Generate some random data to visualise
np.random.seed(2019)
data = np.random.normal(size=100)

stats = {}
# Compute the boxplot stats (as in the default matplotlib implementation)
stats['A'] = cbook.boxplot_stats(data, labels='A')[0]
stats['B'] = cbook.boxplot_stats(data, labels='B')[0]


# For box A compute the 15th and 85th percentiles
stats['A']['q1'], stats['A']['q3'] = np.percentile(data, [25, 75])
# For box B compute the 15th and 85th percentiles
stats['B']['q1'], stats['B']['q3'] = np.percentile(data, [15, 85])


fig, ax = plt.subplots(1, 1)
# Plot boxplots from our computed statistics
ax.bxp([stats['A'], stats['B']], positions=range(2), vert=False)

Output:

enter image description here

Python相关问答推荐

三个给定的坐标可以是矩形的点吗

当多个值具有相同模式时返回空

试图找到Python方法来部分填充numpy数组

使用索引列表列表对列进行切片并获取行方向的向量长度

为什么带有dropna=False的groupby会阻止后续的MultiIndex.dropna()工作?

如何将Docker内部运行的mariadb与主机上Docker外部运行的Python脚本连接起来

Streamlit应用程序中的Plotly条形图中未正确显示Y轴刻度

使用groupby方法移除公共子字符串

Python Tkinter为特定样式调整所有ttkbootstrap或ttk Button填充的大小,适用于所有主题

Python Pandas—时间序列—时间戳缺失时间精确在00:00

在Docker容器(Alpine)上运行的Python应用程序中读取. accdb数据库

如何按row_id/row_number过滤数据帧

在极点中读取、扫描和接收有什么不同?

有没有办法在不先将文件写入内存的情况下做到这一点?

如何在Airflow执行日期中保留日期并将时间转换为00:00

没有内置pip模块的Python3.11--S在做什么?

无法在盐流道中获得柱子

通过对列的其余部分进行采样,在Polars DataFrame中填充_null`?

生产者/消费者-Queue.get by list

根据两个lambda条件筛选组并根据条件创建新列的最佳方式是什么?