分类散点图 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')
相关推荐
FrankHuang88814 小时前
使用高斯朴素贝叶斯算法对鸢尾花数据集进行分类
算法·机器学习·ai·分类
狂小虎20 小时前
01 Deep learning神经网络的编程基础 二分类--吴恩达
深度学习·神经网络·分类
亿牛云爬虫专家1 天前
NLP驱动网页数据分类与抽取实战
python·分类·爬虫代理·电商·代理ip·网页数据·www.goofish.com
电鱼智能的电小鱼2 天前
虚拟现实教育终端技术方案——基于EFISH-SCB-RK3588的全场景国产化替代
linux·网络·人工智能·分类·数据挖掘·vr
Steve lu2 天前
回归任务和分类任务损失函数详解
pytorch·深度学习·神经网络·机器学习·分类·回归
wu_android4 天前
Java 2D 图形类总结与分类
java·分类
白熊1884 天前
【机器学习基础】机器学习入门核心算法:多分类与多标签分类算法
算法·机器学习·分类
三三十二5 天前
MATLAB实战:机器学习分类回归示例
机器学习·matlab·分类·回归
放羊郎5 天前
训练中常见的运动强度分类
分类·运动·跑步·强度·摄氧量
key066 天前
数据分类分级的实践与反思:源自数据分析、治理与安全交叉视角的洞察
安全·分类·数据分析