R语言中 ggplot函数中 annotate选项
001、基础绘图
library(ggplot2) p <- ggplot(faithful, aes(x = eruptions, y = waiting)) + geom_point() ## 基础绘图 p
002、增加文本
p + annotate("text", x = 3, y = 48, label = "Group 1") + annotate("text", x = 4.5, y = 66, label = "Group 2") ## 增加文本
003、 ## 设置颜色、字体、大小等
p + annotate("text", x = 3, y = 48, label = "Group 1", family = "serif", fontface = "italic", colour = "darkred", size = 5) + annotate("text", x = 4.5, y = 66, label = "Group 2", family = "serif", fontface = "italic", colour = "darkred", size = 5) ## 设置颜色、字体、大小等
004、 等价geom_text
p + annotate("text",x=3,y=48,label="Group 1", alpha=.1) + geom_text(x=4.5, y=66, label="Group 2", alpha=.1) ## 等价geom_text
005、指定位置02
p + annotate("text", x = -Inf, y = Inf, label = "Upper left", hjust = -0.2,vjust = 2) + annotate("text", x = mean(range(faithful$eruptions)), y = -Inf, vjust = -0.4, label = "Bottom middle") ## 指定位置02
。
来源:https://blog.csdn.net/g_r_c/article/details/19673625
分类:
R语言
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
2022-07-10 使用plink、gemma软件进行gwas分析增加协变量
2022-07-10 主板EATX、ATX、MATX、ITX
2022-07-10 gemma、plink使用一般线性模型进行GWAS分析
2021-07-10 判断系列向量组的线性相关性a1=(1,1,2,0),a2=(1,2,3,-1), a3=(-1,1,0,-2)
2021-07-10 linux系统中tee命令
2021-07-10 若向量组A可由向量组B线性表示,则R(A) <= R(B)