Reputation: 442
i want to combine two graphs int one graphs : when i try the code bellow :
data_df <- df%>%
filter(!is.na(LayerName)) %>%
dplyr::select(LayerName, A,B) %>%
group_by(LayerName) %>%
dplyr::summarise(lower=min(A),upper=max(A),Mean=mean(A),
lower_out=min(B),upper_out=max(B),Mean_out=mean(B))
c<-ggplot(data = data_df, mapping = aes(x = LayerName, y = Mean)) +
geom_pointrange(mapping = aes(ymin = lower, ymax = upper),color = "red")
r<-c+ggplot(data = data_df, mapping = aes(x = LayerName, y = Mean_out)) +
geom_pointrange(mapping = aes(ymin = lower_out, ymax = upper_out),color = "blue")+
theme_bw()
ggplotly(r)
Don't know how to add ggplot(data = data_df, mapping = aes(x = LayerName, y = Mean_out)) to a plot
Upvotes: 0
Views: 194
Reputation: 4362
You can add extra layers but you want to avoid using ggplot()
twice. So changing your assignment of r like so would probably work:
r<-c +
geom_pointrange(mapping = aes(y = Mean_out, ymin = lower_out, ymax = upper_out), color = "blue") +
theme_bw()
Upvotes: 1