subsetting points in a faceted plot using position_jitterdodge

Try this approach. You can conditionate the alpha parameter acording to y values to assign the transparent level. In your approach you use filters. It is better try to set all aesthetic elements in ggplot2 in order to avoid issues such as not aligning. Here the code:

library(ggplot2)
#Plot
ggplot() +
  geom_point(data = df,
             aes(x=xval, y=yval,
                 color=colorgroup,alpha=ifelse(yval>0.5,0.5,1)),
             position = position_jitterdodge(jitter.width = 0.1)) +
  facet_grid(xfacet ~ yfacet) +
  scale_color_manual(values = c("red", "black", "orange", "blue"))+
  scale_alpha(guide = 'none')

Output:

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top