R 当ggplot有多个图层时如何使用镶嵌网格镜
我正在使用R 当ggplot有多个图层时如何使用镶嵌网格镜,r,ggplot2,R,Ggplot2,我正在使用trelliscopejs包中的facet\u网格镜进行数据可视化。当我的ggplot只有一层时,它工作得很好。但如果我引入第二层,它就不能正确地刻面。例如: # Load packages library(tidyverse) library(trelliscopejs) # Basic stat summary table using iris stat_sum <- iris %>% group_by(Species) %>% summar
trelliscopejs
包中的facet\u网格镜
进行数据可视化。当我的ggplot只有一层时,它工作得很好。但如果我引入第二层,它就不能正确地刻面。例如:
# Load packages
library(tidyverse)
library(trelliscopejs)
# Basic stat summary table using iris
stat_sum <-
iris %>%
group_by(Species) %>%
summarise(l_mean = mean(Sepal.Length))
#Standard ggplot with facet_wrap
ggplot(iris, aes(Sepal.Length, Petal.Width)) +
geom_point() +
geom_vline(data = stat_sum, aes(xintercept = l_mean)) +
facet_wrap(~Species)
我知道我可以操纵一个新的数据框来包含原始数据旁边的统计摘要,但如果可能的话,我不想这样做 多个层可以很好地使用网格镜JS,但在这种特殊情况下,层有自己的数据。已准备好修复程序,以使此案例也能正常工作。对于需要快速修复的任何人,请参阅:。有一个开发分支可用。
# Use facet_trelliscope. Data from stat_sum does not facet
ggplot(iris, aes(Sepal.Length, Petal.Width)) +
geom_point() +
geom_vline(data = stat_sum, aes(xintercept = l_mean)) +
facet_trelliscope(~Species)