我正在尝试使用ggplot2重新创建此可视化的气泡图(我已经找到了在R中执行此操作的代码,但没有使用ggplot2包)。这是我目前的代码。目前我的代码还有一些其他错误,但我想让图例显示大小为同心圆,而不是按行显示圆。谢谢您的帮助!
crime <-
read.csv("http://datasets.flowingdata.com/crimeRatesByState2005.tsv",
header=TRUE, sep="\t")
ggplot(crime,
mapping= aes(x=murder, y=burglary))+
geom_point(aes(size=population), color="red")+
geom_text(aes(label=state.name), show.legend=FALSE, size=3)+
theme(legend.position = c(0.9, 0.2))