我制作了2个名为beta和km的气泡图。我想并排比较这些图,但scale_area似乎不同,这使得很难根据气泡的大小在视觉上比较2个图。
如果您在下面的图中注意到图例,则比例会有所不同。我认为这是因为betaGSD5数据集上的最大BiasAM值~64和kmGSD5数据= 100。
如何手动更改scale_area以使betaPlot比例符合kmPlot比例?
还可以手动设置图例中断吗?而不是自动生成,可以指定我的传说,但我想这样吗? 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
这是beta版代码
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)
KM情节
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)
答案 0 :(得分:10)
如果你想要它们并排,那么它很容易。只需合并两个数据集并使用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)
)