更改气泡图中使用的尺寸范围

时间:2012-07-19 23:32:21

标签: r charts ggplot2

我正在使用R来创建我正在研究的行业中的战略群体的竞争地图。出口数量沿x轴,销售额是y轴以及泡沫的大小。使用的代码:

qplot(data = supermarket, x = outlets, y = sales, size = sales, color = retailer)   

但是,我需要增加气泡的整体尺寸,因为目前还不清楚。请参阅下面的示例。

Graph

我需要的是让气泡保持其相对于销售的尺寸,但总体上变得更大以增加可见度。

1 个答案:

答案 0 :(得分:8)

使用:+ scale_size_continuous(range = c()),如下所示:

#set.seed(10)
#supermarket <- data.frame(sales = sample(1:50000, 12), 
#    outlets = sample(1:3000, 12), retailer = LETTERS[1:12])

#I use ggplot rather than qplot and understand it so that's what I used here
ggplot(data = supermarket, aes(x=outlets, y=sales, size=sales, color=retailer)) + 
            geom_point() + scale_size_continuous(range = c(3, 8))

或者你可以使用你的代码并添加scale_size_continuous作为上面的bdemarest建议:

qplot(data = supermarket, x = outlets, y = sales, size = sales, color = retailer) + 
    scale_size_continuous(range = c(3, 8))

两者都会产生相同的结果。