分类散点图 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')
相关推荐
玉木子1 小时前
机器学习(七)决策树-分类
决策树·机器学习·分类
荒野饮冰室2 小时前
分类、目标检测、实例分割的评估指标
目标检测·计算机视觉·分类·实例分割
盼小辉丶1 天前
Transformer实战(16)——微调Transformer语言模型用于多类别文本分类
深度学习·自然语言处理·分类·transformer
过往入尘土2 天前
从 0 到 1 实现 PyTorch 食物图像分类:核心知识点与完整实
人工智能·pytorch·分类
玉木子2 天前
机器学习(六)朴素贝叶斯分类
开发语言·人工智能·python·算法·机器学习·分类
victory04312 天前
Time-MOE添加MLP分类头进行分类任务
人工智能·分类·数据挖掘
赴3352 天前
食物分类案例优化改进 (数据增强,最优模型保存和使用)
人工智能·分类·数据挖掘·数据增强·保存最优模型
李铁柱的2 天前
数值分析——误差的来源与分类、误差的基本概念(绝对误差、相对误差、有效数字)
人工智能·算法·分类·数据挖掘
dlraba8022 天前
矿物类型分类实战:从数据预处理到多模型对比
人工智能·分类·数据挖掘
THMAIL2 天前
机器学习从入门到精通 - 降维艺术:PCA与t-SNE带你玩转高维数据可视化
人工智能·python·决策树·随机森林·机器学习·分类·bootstrap