Ggplot2: how to manually adjust scale_area

I made 2 bubble charts called beta and km. I would like to compare the graphs with each other, but scale_area seems different, which makes it difficult to visually compare the two graphs based on the size of the bubbles.

If you notice the legends in the graphs below, the scales are different. I think this is because the highest BiasAM value in the betaGSD5 ~ 64 dataset and kmGSD5 = 100.

How can I manually change the scale_area so that the betaPlot scale matches the kmPlot scale?

Can you also manually set legend breaks? Instead of being automatically generated, you can specify a legend, but I want how to do it? 0-10, 10-30, 30-50, 50-70, 70-100,

100

betaGSD5: https://dl.dropbox.com/u/63947093/betaGSD5.csv

kmGSD5: https://dl.dropbox.com/u/63947093/kmGSD5.csv

Here is the beta code

betaPlot <- ggplot(betaGSD5, aes(N,PctCens,size=BiasAM,label=NULL)) +
  geom_point(colour="red", shape=16) +scale_area(to=c(1,10)) +
  xlab("Sample size") + ylab("Percent censored") +
  xlim(0,100)+ ylim(0,100) +
  theme_bw()+
  opts(
 #legend.position='none',
  panel.grid.minor = theme_blank(),
  panel.background = theme_blank(),
  axis.ticks = theme_blank(),
  axis.title.x=theme_text(face='bold',vjust=0.2, size =12), #size=15 #hjust:move     horizonal, vjust-move verticall
  axis.title.y=theme_text(face='bold',angle=90, vjust=0.2,size =12))
print(betaPlot)

enter image description here

KM chart

kmPlot <- ggplot(kmGSD5, aes(N,PctCens,size=NewBiasAMpct,label=NULL)) +
    geom_point(colour="red", shape=16) +scale_area(to=c(1,10)) +
    xlab("Sample size") + ylab("Percent censored") +
    xlim(0,100)+ ylim(0,100) +
    theme_bw()+
    opts(
      #legend.position='none',
     panel.grid.minor = theme_blank(),
     panel.background = theme_blank(),
     axis.ticks = theme_blank(),
     axis.title.x=theme_text(face='bold',vjust=0.2, size =12), #size=15 #hjust:move       horizonal, vjust-move verticall
     axis.title.y=theme_text(face='bold',angle=90, vjust=0.2,size =12))

 print(kmPlot)

enter image description here

+5
source share
1 answer

If you want them side by side, then it is very easy. Just combine both datasets and use facet_wrap ()

ggplot(dataset, aes(x = N, y = PctCens, size = BiasAM, label = NULL)) +
  geom_point(colour="red", shape = 16) + 
  scale_size_area(limits = c(1, 10), breaks = c(0, 10, 30, 50, 70, 100)) +
  scale_x_continuous("Sample size", limits = c(0, 100)) + 
  scale_y_continuous("Percent censored", limits = c(0, 100)) +
  facet_wrap(~ Method) + 
  theme_bw() +
  theme(
    panel.grid.minor = element_blank(),
    panel.background = element_blank(),
    axis.ticks = element_blank(),
    axis.title.x = element_text(face = 'bold', vjust = 0.2, size = 12),
    axis.title.y = element_text(face = 'bold', angle = 90, vjust = 0.2, size = 12)
  )

enter image description here

+9
source

All Articles