Draw Two Data Sets with Different Sizes in ggplot2 Plot in R (Example) | Point Size in Scatterplot

preview_player
Показать описание
R code of this video:

y = rnorm(1000))

y = rnorm(10))

library("ggplot2")

ggp1 <- ggplot(NULL, aes(x, y)) + # Draw two data frames in ggplot2 plot
geom_point(data = data_large,
col = "#1b98e0") +
geom_point(data = data_small,
col = "red",
size = 5)
ggp1

data_small),
col = c(rep("#1b98e0", nrow(data_large)),
rep("red", nrow(data_small))),
size = c(rep(1.5, nrow(data_large)),
rep(5, nrow(data_small))))

ggp2 <- ggplot(data_all, aes(x, y)) + # Draw combined data frame
geom_point(col = data_all$col,
size = data_all$size)
ggp2

Follow me on Social Media:

Рекомендации по теме
Комментарии
Автор

Thank you! I always wanted to know how to do it.

johneagle
Автор

This method can be used to highlight subset of the data.

yinghuiliu
visit shbcf.ru