Same scale of geom point size for two separate ggplot

Viewed 105

When we create two separate plot with ggplot, the scale (for the size of geom point for example) is independent.

library(ggplot)
library(ggpubr)

df1=data.frame(x=1:10,y=1:10,s=1:10)
p1=ggplot(df1,aes(x,y,size=s))+geom_point()

df2=data.frame(x=1:10,y=1:10,s=1:10*10)
p2=ggplot(df2,aes(x,y,size=s))+geom_point()


ggarrange(p1,p2)

enter image description here

In this combined graph, we can see that the size of the points appeared to be the same, whereas the value is not the same. Is it possible to fix the scale for the two plots.

One solution is to use facet_wrap after rbinding

df1$group=1
df2$group=2

ggplot(rbind(df1,df2),aes(x,y,size=s))+
  geom_point()+
  facet_wrap(~as.factor(group))

enter image description here

But for some reason, I would not bind the datasets.

0 Answers
Related