分类散点图 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')
相关推荐
Mr.看海5 小时前
【终审稿】CNN-RNN 通用分类算法及 MATLAB 实现
rnn·分类·cnn
丨白色风车丨6 小时前
PyTorch 迁移学习实战:ResNet18 实现 20 类食物图像分类(完整可运行代码)
pytorch·分类·迁移学习
BOTTLE_平10 小时前
AI认知篇:AI是什么 与 核心分类体系
人工智能·机器学习·分类·语音识别
解局易否结局2 天前
鸿蒙端侧 NLP 实战:分词器 + TF-IDF + 朴素贝叶斯分类 + 文本相似度
华为·自然语言处理·分类·harmonyos·tf-idf
All The Way North-3 天前
【TorchMetrics精通系列①】核心设计哲学 + Accuracy 超详解
机器学习·分类·模型评估·accuracy·准确率·评估指标·torchmetrics
皓悦编程记5 天前
【YOLO26 系列】基于YOLO26的垃圾分类检测系统【python源码+Pyqt5界面/WEB+数据集+训练代码】
python·qt·分类
有Li7 天前
通过渐进式域变换实现组织分类的无监督单域泛化文献速递/基于多模态的医学影像分割与理解
人工智能·学习·分类·数据挖掘·文献·医学生
YOLO数据集集合7 天前
果蔬视觉识别数据集全量使用指南|计算机视觉图像分类工程落地|PyTorch迁移学习训练全流程
pytorch·计算机视觉·分类
程序员羽痕8 天前
基于深度学习的眼疾识别系统
人工智能·pytorch·深度学习·分类·django
八解毒剂9 天前
计算机分类
分类