首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何注释ggplot中的行?

如何注释ggplot中的行?
EN

Stack Overflow用户
提问于 2018-11-06 00:06:40
回答 1查看 5.8K关注 0票数 0

我想用因子变量(chain.length)来注释每一行,如图所示。我该怎么做呢?

这是上面图片的代码。

代码语言:javascript
复制
  ggplot(mz_rt, aes(rt, mz, size = acex, colour = as.factor(double.bonds))) +
  geom_line(aes(group = as.factor(chain.len)), colour = "grey", size = 0.3) +
  geom_point() +
  scale_radius(breaks = seq(from = 0, to = 1, by = 0.2)) +
  theme(legend.position="bottom") +
  theme_light()
EN

回答 1

Stack Overflow用户

发布于 2018-11-06 00:19:21

通过注解函数(https://ggplot2.tidyverse.org/reference/annotate.html)创建注释层。您需要指定定位美学。

代码语言:javascript
复制
library(tidyverse)
library(ggplot2)
data(iris)
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species)) +
    geom_point(size = 1.5 ,alpha = 0.7) +
    annotate("segment", x = 5, xend = 5.5, y = 2.2, yend = 2.4, colour = "blue") +
    annotate("text", x = 5, y = 2.15, label = "Some text")

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53158006

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档