Please, help me with this point. I need the positive values to be represented as small points and negative as large points. If I tape minus before size, the point sizes are right but the legend is changing:
df=data.frame(x=rnorm(20),y=runif(20),z=rnorm(20))
ggplot(df,aes(x=x,y=y))+geom_point(aes(size=-z))
so that does not suite.
To change the size of dots in dotplot created by using ggplot2, we can use binwidth argument inside geom_dotplot.
The function geom_point() adds a layer of points to your plot, which creates a scatterplot.
geom_count is a variant of geom_point that counts the number of observations at each location, then maps the count to point area. It is useful when you have discrete data with overplotting.
Little late, but an easier way would just to add trans='reverse'
to scale_size.
Example:
df=data.frame(x=rnorm(20),y=runif(20),z=z=(-13:6))
ggplot(df,aes(x=x,y=y))+
geom_point(aes(size=z)) +
scale_size(trans = 'reverse')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With