ggplot2 - R ggplot - adding all data points to all facets -


until can't find appropriate answer, here short question ggplot2 in r:

data(mtcars) ggplot(data=mtcars, aes(x=mpg, y=wt, fill=factor(cyl))) + scale_fill_manual(values=c("red","orange","blue"))+ geom_point(size=2, pch=21)+ facet_grid(.~cyl) 

enter image description here

this fine, want data points (regardless number cyl has) in every facet (e.g. smooth grey below points)?

thanks, michael

using link given @beetroot, able :

g1 <- ggplot(data=mtcars, aes(x=mpg, y=wt)) +    geom_point(data=mtcars[, c("mpg", "wt")], aes(x=mpg, y=wt), colour="grey") +   geom_point(size=2, pch=21, aes(fill=factor(cyl))) +    scale_fill_manual(values=c("red","orange","blue")) +    facet_wrap(~cyl)  

this produces plot : enter image description here

hope helps you.


Comments

Popular posts from this blog

python - Setting ctypes.Structure default values -

Ansible - ERROR! the field 'hosts' is required but was not set -

java - HTTP Status 500 - No data type for node: org.hibernate.hql.internal.ast.tree.IdentNode -