I have a large dataset that I am plotting using a scatter plot. These points have a unique combination of x,y and therefore they don't overlap, but some of them are very close to each other therefore I'm plotitng them with small size.
1- How to produce smaller point symbols (smaller size
) so that the areas are proportional. In this example, the last point does not have an area proportional to the size
. I was expecting it 10 smaller than the middle one eg:
df <- data.frame(c1 = 1:3, c2 = c(1,1,1))
ggplot(df) + geom_point(aes(x= c1, y = c2), size = c(1, 0.1, 0.01))
2- How does the size
in ggplot2 matches the R graphics cex
argument eg: plot(df$c2 ~ df$c1, cex = c(1, 0.1, 0.01))
. Thanks
You can try
geom_point(shape = ".")
this will make the point 1 pixel in size.
This is from page 70 of ggplot2 second edition by H Wickham
There is a size =
argument to geom_point
, but you either specify a size for all points:
+ geom_point(size = 0.5)
Or you map the size to one of the columns in your data using aes
:
+ geom_point(aes(size = c2))
In the latter case, you can control the range of sizes using scale_size_continuous
. The default is min = 1, max = 6. To get eg min = 2, max = 8:
+ geom_point(aes(size = c2)) + scale_size_continuous(range = c(2, 8))
cex
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.