網站首頁 編程語言 正文
今天給大家介紹一下Ridgeline plot(山脊圖)的畫法。
作圖數據如下:
Step1. 繪圖數據的準備
首先要把你想要繪圖的數據調整成R語言可以識別的格式,建議大家在excel中保存成csv格式。
Step2. 繪圖數據的讀取
data<-read.csv(“your file path”, header = T) #注釋:header=T表示數據中的第一行是列名,如果沒有列名就用header=F
Step3. 繪圖所需package的安裝、調用
library(reshape2) library(ggplot2) library(ggridges) # 注釋:package使用之前需要調用 # 今天要用到geom_density_ridges()函數需要調用ggridges包 # 直接用install.packages(ggridges)可以安裝
Step4. 繪圖
ggplot(data_melt, aes(x = value , y = variable , fill = variable)) + geom_density_ridges() + theme_ridges() + theme(legend.position = "none")
調整透明度
ggplot(data_melt, aes(x = value , y = variable , fill = variable)) + geom_density_ridges(alpha = 0.5) + theme_ridges() + theme(legend.position = "none")
更改順序
level<-levels(data_melt$variable) data_melt$variable<-factor(data_melt$variable, levels = rev(level)) ggplot(data_melt, aes(x = value , y = variable , fill = variable)) + geom_density_ridges(alpha = 0.5) + theme_ridges() + theme(legend.position = "none")
更改線條形狀
ggplot(data_melt, aes(x = value , y = variable , fill = variable)) + geom_density_ridges(alpha = 0.5, stat="binline", bins=20) + theme_ridges() + theme(legend.position = "none")
原文鏈接:https://blog.csdn.net/biocity/article/details/107570578
相關推薦
- 2024-01-05 IIS WebApi: 文件上傳,大小限制,提示413 (Request Entity Too La
- 2022-05-29 MVC使用MvcPager實現分頁效果_實用技巧
- 2022-09-04 關于Python下的Matlab函數對應關系(Numpy)_python
- 2022-12-03 React前端解鏈表數據結構示例詳解_React
- 2022-10-20 Swift?Error的處理方法說明_Swift
- 2022-08-15 關于PL/SQL進行更新操作時卡死的解決辦法
- 2022-05-05 Nginx配置ssl實現https的全過程記錄_nginx
- 2022-10-12 docker配置阿里云鏡像倉庫的實現_docker
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支