Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 我如何获得泡泡糖呢?_R_Plot_Scatter_Po - Fatal编程技术网

R 我如何获得泡泡糖呢?

R 我如何获得泡泡糖呢?,r,plot,scatter,po,R,Plot,Scatter,Po,我如何在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 =


我如何在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))
require(ggplot2)

df除了太宽(和一般较差的q)之外,它也是一个复制品-这太棒了!非常感谢。