Make geom more dense in ggplot
I am currently displaying values ββas Geoms on ggplot
. These values ββare on the y-axis, and their categories are on the x-axis.
The data looks something like this:
Value condition
1 TRUE
1 TRUE
1 TRUE
6 TRUE
10 TRUE
Minimal run example:
df <- data.frame(c(1,1,1,1,1,2,3,3,1,6), TRUE)
colnames(df) <- c("value", "condition")
ggplot(df, aes(x = condition, y = value)) + geom_point()
So, for example, given a value 1
provided TRUE
, how could I make a point (or any other) larger than the others, since it has more data points.
6 units have more data points than 3 three or 1 two or 1 six. So one of them will be the largest in this example, 3 will be next, while 2 and 6 will be the same size
source to share
Using the package dplyr
, you can change your details. Then you can draw the shape.
mydf <- data.frame(c(1,1,1,1,1,1,2,3,3,1,6), TRUE)
colnames(mydf) <- c("value", "condition")
library(dplyr)
count(mydf, condition, value) -> mydf2
ggplot(mydf2, aes(x = condition, y = value, size = n)) + geom_point()
source to share