Ggplot2 - geom_point in terms of two size variables

Can I use two variables in a parameter size

in a function ggplot

? For example.

ggplot(mtcars, aes(qsec,drat, size = cyl))+
   geom_point()

      

Obviously this works and the size of the points depends on the variable cyl

. But is it possible to add another variable size

that can use an option alpha

, eg. variable = mpg

... How to do it?

I only did this for three points as an example in Ilustrator. enter image description here

Thank,

Update

Thanks to @lukeA the following lines of code work:

ggplot() + 
    geom_point(data = mtcars, aes(qsec,drat, size = cyl)) + 
    geom_point(data = mtcars, aes(qsec,drat, size = mpg), alpha = .1, colour = "red")

      

But when I want to set the size of each variable separately, this is not possible. When there is one variable size

, I usually use it scale_size_contiunous

, but size

it doesn't work with two variables . I know using it scale_size_continuous

twice doesn't change anything. It may not be possible at all, but maybe someone will find a solution.

+3


source to share





All Articles