I have the following code and would like to know if it is possible to use different shapes in the scale_size_binned command. In my actual data, it is a bit difficult to distinguish between the points so I would like to use different shapes for them. Any suggestions will be appreciated.
rct <- data.frame(
Effect_Size_Study = rnorm(100),
F_test_var_stat = runif(100),
Outcome_Sample_Size = runif(100, min = 6, max = 10000)
)
ggplot(rct, aes(x = Effect_Size_Study, y = F_test_var_stat))
geom_point(aes(size = Outcome_Sample_Size))
scale_size_binned_area(
limits = c(0, 10000),
breaks = c(0, 100, 500, 1000, 5000, 10000),
)
CodePudding user response:
You could use scale_shape_binned
like this:
library(ggplot2)
rct <- data.frame(
Effect_Size_Study = rnorm(100),
F_test_var_stat = runif(100),
Outcome_Sample_Size = runif(100, min = 6, max = 10000)
)
ggplot(rct, aes(x = Effect_Size_Study, y = F_test_var_stat))
geom_point(aes(size = Outcome_Sample_Size, shape = Outcome_Sample_Size))
scale_size_binned_area(
limits = c(0, 10000),
breaks = c(0, 100, 500, 1000, 5000, 10000),
)
scale_shape_binned()
Created on 2022-08-11 by the reprex package (v2.0.1)
CodePudding user response:
We can combine the shape and size legend together. This is not much different from the other answer, except the legend.
library(ggplot2)
set.seed(123)
rct <- data.frame(Effect_Size_Study = rnorm(100),
F_test_var_stat = runif(100),
Outcome_Sample_Size = runif(100, min = 6, max = 10000))
ggplot(rct, aes(x = Effect_Size_Study, y = F_test_var_stat))
geom_point(aes(size = Outcome_Sample_Size, shape = Outcome_Sample_Size))
scale_size_binned_area(name = "Outcome Sample",
limits = c(0, 10000),
breaks = c(0, 100, 500, 1000, 5000, 10000),
labels = c(0, 100, 500, 1000, 5000, 10000))
scale_shape_binned(name = "Outcome Sample",
limits = c(0, 10000),
breaks = c(0, 100, 500, 1000, 5000, 10000),
labels = c(0, 100, 500, 1000, 5000, 10000))