【发布时间】:2021-05-11 00:07:00
【问题描述】:
我有一个值列表和一个 ggplots 列表。我想将列表中的值附加到 ggplots 上。有什么好办法吗?
这就是我所拥有的 ggplots 列表:
p.list <- lapply(sort(unique(ind_steps$AnimalID)), function(i){
ggplot(ind_steps[ind_steps$AnimalID == i,], aes(x = t2, y = NSD)) +
geom_line() + theme_bw() +
theme(axis.text.x = element_text(angle = 90)) +
scale_x_datetime(date_breaks = '10 days', date_labels = '%y%j') +
facet_grid( ~ AnimalID, scales = "free") +
scale_colour_manual(values=hcl(seq(15,365,length.out=4)[match(i, sort(unique(ind_steps$AnimalID)))], 100, 65))
})
假设我有另一个与这个长度相同的列表,并且每个列表中都有一个值。
我想将 ggplots 与值列表配对,并让值显示在每个相应的图中。我的预期输出是让值列表中的每个值都位于图列表中的每个相应图上。
【问题讨论】:
-
能否分享一下预期的输出,情节如何? stackoverflow.com/questions/5963269/…
-
如果您包含一个简单的reproducible example,其中包含可用于测试和验证可能解决方案的示例输入和所需输出,则更容易为您提供帮助。