網站首頁 編程語言 正文
1. 修改圖例標注/標簽
內容修改、序列修改
##標注排序修改breaks,breaks——labels,
p + scale_colour_discrete(#values=c("#CC0000", "#006600", "#669999",
# "#00CCCC", "#660099"),或者color/fill/colour,discrete/hue,
name="Experimental",
breaks = c("6","4","8"),
labels = c("B","A","C"))
2. 修改圖例標題名稱
##第一種color/fill/colour,discrete/hue
p + scale_colour_discrete(
name="Experimental",
breaks = c("6","4","8"),
labels = c("B","A","C"))
##第二種修改圖例標題
p + labs(colour = "name1", shape = "name2")
3. 隱藏/刪除圖例標題 標題修改、刪除
#第一種,
#Remove title for fill legend
p + guides(colour=guide_legend(title=NULL)) #注意colour/fill/color/shape轉換
#第二種,所有的表題全部移除
# Remove title for all legends
p + theme(legend.title=element_blank())
4.圖例位置
#1: around the plot "none", "left", "right", "bottom", "top"
basic + theme(legend.position = "bottom")
#2:inside the plot
basic + theme(
legend.position = c(.95, .95),#plot內位置
legend.justification = c("right", "top"),#固定右上角
legend.background = element_blank(),#圖例背景色
legend.key = element_blank(),#圖標背景色element_rect(colour="black")
legend.box.background = element_rect(fill=NA,color = "black",linetype = 1) #圖例外框和背景色默認填充白色(刪除fill=NA)
#legend.box.just = "right",
#legend.margin = margin(6, 6, 6, 6)#邊框大小調整
)
圖片呈現是的3
5. 刪除圖例
#刪除其中一個圖例
guides(shape=FALSE) #shape/color/colour/fill
#全部刪除圖例
theme(legend.position = "none")
引用
- R語言之可視化①⑨子ggplot2中的圖例修改
- ggplot2-設置圖例(legend)
總結
原文鏈接:https://blog.csdn.net/LeaningR/article/details/114576555
相關推薦
- 2022-10-07 android?studio廣播機制使用詳解_Android
- 2022-05-23 C#中的數據結構介紹_C#教程
- 2022-03-30 C語言入門之淺談數據類型和變量常量_C 語言
- 2022-05-02 dubbo服務使用redis注冊中心的系列異常解決_Redis
- 2022-09-22 Apriori算法的實現
- 2022-08-03 GoFrame?glist?基礎使用和自定義遍歷_Golang
- 2022-02-20 Hive-SQL查詢連續活躍登錄用戶思路詳解_MsSql
- 2023-04-26 C語言二維數組指針的概念及使用_C 語言
- 最近更新
-
- 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同步修改后的遠程分支