Changing the range of sizes used in a bubble plot

2020-03-13 06:14发布

问题:

I'm using R to create a competitive map of strategic groups in the industry I'm researching. The number of outlets is along the x-axis, Sales is the y-axis as well as the size of the bubble. Code used:

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

However, I need to increase the overall size of the bubbles as it is too unclear at the moment. Please see below for an example.

What I need is to have the bubbles keep their size relative to sales but become larger overall to increase the visibility.

回答1:

Play with: + scale_size_continuous(range = c()) as in:

#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))

Or you can just use your code and add the scale_size_continuous as bdemarest suggests above:

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

Both will yield the same results.



标签: r charts ggplot2