How to remove a group of point points in geom_point ggplot

I have a problem with the plot. I want to show only point points in group A, and not in every name. Here is an example:

name <- c("a","b","c","d")
df <- data.frame(id = rep(1:5,3), 
             value = c(seq(50,58,2),seq(60,68,2),seq(70,78,2)),
             name = c(rep("A",5),rep("B",5),rep("C",5)),
             type = rep(c("a","b","c","d","r"),3))

df$name <- factor(df$name, levels = c("C","B","A"),ordered = TRUE)
ggplot(df, aes(id, value, fill = name,color = type))+
    geom_area( position = 'identity', linetype = 1, size = 1 ,colour="black") +
    geom_point(size = 8)+
    guides(fill = guide_legend(override.aes = list(colour = NULL, shape = NA)))

enter image description here

+4
source share
1 answer

If I read the question correctly, it seems that you only need points for the blue area. In this case, you can multiply the data and use it for geom_point.

ggplot(df, aes(id, value, fill = name,color = type))+
geom_area( position = 'identity', linetype = 1, size = 1 ,colour="black") +
geom_point(data = subset(df, name == "A"), size = 8) +
guides(fill = guide_legend(override.aes = list(colour = NULL, shape = NA)))

enter image description here

+3
source

All Articles