当前位置: 首页 > news >正文

boxplot 绘制箱线图,添加数据点

先看效果图
在这里插入图片描述

import matplotlib.pyplot as plt 
#! 解决不显示的问题:中文设置为宋体格式
plt.rcParams['font.family'] = ["Times New Roman", 'SimSun']def plot_boxplot(data_list, out_file, x_custom_labels):# 画图fig, ax = plt.subplots(figsize=(90, 60))ax.boxplot(data_list,notch=True,vert=True, patch_artist=True)# 添加数据点for i, d in enumerate(data_list):y = dx = np.random.normal(i+1, 0.04, len(y))ax.plot(x, y, 'r.', alpha=0.5, markersize=10)#刻度值字体大小设置(x轴和y轴同时设置)plt.tick_params(labelsize=20)# 自定义 X 轴标签ax.set_xticklabels(x_custom_labels, rotation=45, ha='right', fontweight='bold')plt.xticks(fontweight='bold' )# 添加网格线ax.yaxis.grid(True, linestyle='--', which='major', color='grey', alpha=.45)ax.xaxis.grid(True, linestyle='--', which='major', color='grey', alpha=.45)plt.title(f'Boxplot Plots for {down_lvl}G', fontsize=80)plt.xlabel('Site', fontsize=50)plt.ylabel('Depth', fontsize=50)plt.legend()# # 调整子图间距plt.tight_layout()# 显示图形plt.show()plt.savefig(out_file)
http://www.lryc.cn/news/459859.html

相关文章:

  • 用sdkman管理多个jdk切换
  • 【AIGC】ChatGPT提示词Prompt高效编写模式:结构化Prompt、提示词生成器与单样本/少样本提示
  • 反调式实战(有道翻译窗口弹出)
  • verilog端口使用注意事项
  • Docker常用命令大全汇总
  • LVS-DR+Keepalived 高可用群集部署
  • 【elasticsearch】安装和启动
  • Golang 逃逸分析(Escape Analysis)理解与实践篇
  • React入门 9:React Router
  • MATLAB基础应用精讲-【数模应用】Bland-Altman图(附python和R语言代码实现)
  • ARM/Linux嵌入式面经(四一):中兴面经
  • 鸿蒙虚拟运行环境
  • SpringCloud-Consul
  • nginx搭建负载均衡
  • 灵当CRM data/pdf.php 任意文件读取漏洞复现
  • Python 批量转换 Shapefile 为 GeoJSON
  • 软考《信息系统运行管理员》- 4.1信息系统软件运维概述
  • Leetcode 3319. K-th Largest Perfect Subtree Size in Binary Tree
  • 从秒级到小时级:TikTok等发布首篇面向长视频理解的多模态大语言模型全面综述
  • 【CTF】敏感信息泄露 GIT SVN VIM
  • EMQX服务器的搭建,实现本地机和虚拟机之间的MQTT通信(详细教程)
  • cordova的使用
  • 三种Transformer模型中的注意力机制介绍及Pytorch实现:从自注意力到因果自注意力
  • 《使用Gin框架构建分布式应用》阅读笔记:p20-p31
  • 如何修改MacOS的终端的配色和linux一样
  • 基于百度智能体开发爱情三十六计
  • 计算机网络:计算机网络概述 —— 描述计算机网络的参数
  • Windows 11系统选项卡详解:从新手到专家的操作指南
  • 乐鑫ESP32-S3无线方案,AI大模型中控屏智能升级,提升智能家居用户体验
  • postman变量,断言,参数化