如何实现气泡图?
How do I achieve a bubbleplot?
我将如何在 R 上实现这样的气泡图?
为此,您可以使用 ggplot。举个例子:
require(ggplot2)
df <- data.frame(x = c(-2, -1.5, 1, 2, 3),
y = c(-1, 0.8, 1, 1, 2),
country = c("SWI", "FRA", "US", "UK", "NL"), size = c(15,12,20,4,7))
ggplot(df, aes(x = x, y = y)) + geom_point(aes(size = size), pch=1) +geom_text(aes(label=country),hjust=-0.5, vjust=0) + xlim(c(-3,4)) + scale_size_continuous(range = c(2,20))
我将如何在 R 上实现这样的气泡图?
为此,您可以使用 ggplot。举个例子:
require(ggplot2)
df <- data.frame(x = c(-2, -1.5, 1, 2, 3),
y = c(-1, 0.8, 1, 1, 2),
country = c("SWI", "FRA", "US", "UK", "NL"), size = c(15,12,20,4,7))
ggplot(df, aes(x = x, y = y)) + geom_point(aes(size = size), pch=1) +geom_text(aes(label=country),hjust=-0.5, vjust=0) + xlim(c(-3,4)) + scale_size_continuous(range = c(2,20))