【发布时间】:2015-07-23 07:49:22
【问题描述】:
我遇到了一个气泡图教程here,我正在重用其代码以进行澄清。请在下面找到代码:
crime <-read.csv("http://datasets.flowingdata.com/crimeRatesByState2005.tsv", header=TRUE, sep="\t")
popIndex <- crime$population/max(crime$population)
crime.new <- cbind(crime,popIndex)
ggplot(crime, aes(x=murder, y=burglary, size=population, label=state),guide=FALSE)+
geom_point(colour="white", fill="#E69F00", shape=21)+ scale_size_area(max_size = 22)+
scale_x_continuous(name="Murders per 1,000 population", limits=c(0,12))+
scale_y_continuous(name="Burglaries per 1,000 population", limits=c(0,1250))+
geom_text(size=4)+
theme_bw()
在此图中,气泡大小由人口决定。我的问题是,如果我必须使用气泡颜色在图中容纳 popIndex 变量,我该怎么做?
【问题讨论】:
标签: r ggplot2 bubble-chart