網站首頁 編程語言 正文
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-06-15 C語言詳解實現字符菱形的方法_C 語言
- 2022-10-14 nginx gzip 壓縮配置
- 2023-07-07 Linux服務器zip安裝,及壓縮解壓
- 2022-09-16 一文詳解Python中復合語句的用法_python
- 2022-06-28 python神經網絡Keras構建CNN網絡訓練_python
- 2022-04-11 python寫入Excel表格的方法詳解_python
- 2022-10-16 epoll多路復用的一個實例程序(C實現)_C 語言
- 2022-02-17 Error: Network Error
- 最近更新
-
- 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同步修改后的遠程分支