分类散点图 stripplot() 加辅助线axhline() 多图合一

分类散点图 stripplot 加辅助线axhline 多图合一

画图没有什么可说的,直接上图

效果图

代码

python 复制代码
# 绘制图, 查看是否数值在阈值上
plt.figure(figsize=(30, 18))
n = 0
for header, value_list in info_dict.items():
    ref_value_list = ref_info_dict[header]
    threshold = 1000
    if header == 'uniformity':
        threshold = 0.9
    elif header in ('median_depth', 'average_depth'):
        threshold = 900
    elif header in ('dedup_median_depth', 'dedup_average_depth'):
        threshold = 200
    print(threshold)
    n += 1
    plt.subplot(3, 3, n)
    # 将数据合并为数据框
    df = pd.DataFrame({'Group': ['test']*len(value_list) + ['ref']*len(ref_value_list),
                   'Value': value_list + ref_value_list})
    # 添加每个值的 stripplot, palette 指定调色板颜色
    sns.stripplot(x='Group', y='Value', data=df, dodge=True, alpha=0.5, jitter=True, palette=['blue', 'green'])
    plt.axhline(y=threshold, color='red', linestyle='--', label='threshold Line')
    # 添加直线上的数值标签
    plt.text(0, threshold, threshold, color='red', fontsize=20)
    plt.title(header)
# 添加大图标题
plt.suptitle('大图标题', fontsize=30)
# 显示图例
plt.legend()
# 调整子图之间的间距
plt.tight_layout()
# 显示图形
plt.show()
plt.savefig('tmp.jpg')
相关推荐
估值探索者2 天前
【Python量化系统工程化 #08】关了 SSH 就停?systemd 让脚本开机自启 + 异常自动拉起
java·c++·人工智能·分类·数据挖掘
Rudon滨海渔村6 天前
免费开源的Web版windows画图软件 - 简单画画 - js Paint
开源·画图·ms·画画
YOLO数据集集合9 天前
无人机航拍建筑与拆除废物检测数据集 | 建筑垃圾 无人机巡检 废物分类 资源回收 目标检测10042期
目标检测·分类·无人机
陈年老古董9 天前
PyTorch食物图像分类实战:从数据集制作到CNN模型训练全流程详解
pytorch·深度学习·学习·机器学习·分类·cnn
估值探索者10 天前
【AI+量化实战 #05】财报季的信息洪流:用LLM给业绩预告分类+算事件窗口收益
java·c语言·c++·人工智能·python·分类·数据挖掘
派大_星11 天前
基于 PyTorch 的 CNN 图片分类学习
pytorch·分类·cnn
磁场转动100万匹11 天前
PyTorch 食物图像分类实战:从数据准备到 CNN 训练全流程解析
pytorch·分类·cnn
adaierya11 天前
用 AI 解决音频转换编程问题
开发语言·人工智能·python·分类·ai编程
天行健,君子而铎12 天前
数据分类分级的范式转换:从规则匹配到模型持续优化规模化前瞻算法
大数据·网络·数据库·安全·分类
HineMusk13 天前
如何使用 Codex 为数学建模论文高效绘图:以 2023 国赛 C 题为例
数学建模·流程图·画图