Hello, we want to plot a proportional symbol map with ggplot. Symbols' area should have the same proportions as the scaled variable. Hereby an example we found on http://www.r-bloggers.com/bubble-chart-by-using-ggplot2/ . In this example we see the proportions of the symbols' area are different from the proportions of the scaled variable: crime <- read.csv("http://datasets.flowingdata.com/crimeRatesByState2008.csv", header=TRUE, sep="\t") p <- ggplot(crime, aes(murder,burglary,size=population, label=state)) p <- p+geom_point(colour="red") +scale_area(to=c(1,20))+geom_text(size=3) Example: proportion population Pennsylvania/Tennessee= 2.003 proportion symbols' area Pennsylvania/Tennessee= +/- 2.50 proportion population California/Florida= 2.005 proportion symbols' area California/Florida= +/-2.25 What we would like is that the proportion of the symbols' area is also equal to 2.0. We see the same in the legend: proportion population 1.6e+07 / 4.0e+06 = 4.0 proportion symbols' area 1.6e+07 / 4.0e+06= +/-5.0 Thanks in advance! Ann Frederix Robbie Heremans
Hello Scott, Thank you for the tips (I have posted the issue on the google group too), but there's nothing on these or other websites that gives an answer on our question. Following the traditional used rules of making a symbol plot, the used symbols should have the same proportions, based on area, then the values have. Unfortunately, this is not so in the plots we make with the code below (scale_area). Yours sincerely, Ann Frederix ----- Original Message ----- From: Scott Chamberlain To: Strategische Analyse CSD Hasselt Sent: Monday, March 14, 2011 4:05 PM Subject: Re: [R] proportional symbol map ggplot There is a ggplot2 google groups mailing list that you may get more appropriate help from: http://groups.google.com/group/ggplot2?pli=1 and the ggplot2 website is very helpful http://had.co.nz/ggplot2/ On Monday, March 14, 2011 at 9:41 AM, Strategische Analyse CSD Hasselt wrote: Hello, we want to plot a proportional symbol map with ggplot. Symbols' area should have the same proportions as the scaled variable. Hereby an example we found on http://www.r-bloggers.com/bubble-chart-by-using-ggplot2/ . In this example we see the proportions of the symbols' area are different from the proportions of the scaled variable: crime <- read.csv("http://datasets.flowingdata.com/crimeRatesByState2008.csv", header=TRUE, sep="\t") p <- ggplot(crime, aes(murder,burglary,size=population, label=state)) p <- p+geom_point(colour="red") +scale_area(to=c(1,20))+geom_text(size=3) Example: proportion population Pennsylvania/Tennessee= 2.003 proportion symbols' area Pennsylvania/Tennessee= +/- 2.50 proportion population California/Florida= 2.005 proportion symbols' area California/Florida= +/-2.25 What we would like is that the proportion of the symbols' area is also equal to 2.0. We see the same in the legend: proportion population 1.6e+07 / 4.0e+06 = 4.0 proportion symbols' area 1.6e+07 / 4.0e+06= +/-5.0 Thanks in advance! Ann Frederix Robbie Heremans ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. [[alternative HTML version deleted]]
On Mon, Mar 14, 2011 at 9:41 AM, Strategische Analyse CSD Hasselt <csd.sa at fedpolhasselt.be> wrote:> Hello, > > we want to plot a proportional symbol map with ggplot. Symbols' area should > have the same proportions as the scaled variable. > Hereby an example we found on > http://www.r-bloggers.com/bubble-chart-by-using-ggplot2/ . In this example > we see the proportions of the symbols' area are different from the > proportions of the scaled variable: > > crime <- > read.csv("http://datasets.flowingdata.com/crimeRatesByState2008.csv", > header=TRUE, sep="\t") > p <- ggplot(crime, aes(murder,burglary,size=population, label=state)) > p <- p+geom_point(colour="red") +scale_area(to=c(1,20))+geom_text(size=3) > > Example: > proportion population Pennsylvania/Tennessee= 2.003 > proportion symbols' area Pennsylvania/Tennessee= +/- 2.50 > > proportion population California/Florida= 2.005 > proportion symbols' area California/Florida= +/-2.25 > > What we would like is that the proportion of the symbols' area is also equal > to 2.0.To do that you need to make sure the lower limit extends to 0 and the size of the smallest circle is also 0. I think something like scale_area(to=c(0, 20), limits = c(0, 4e7), breaks = 1:4 * 1e7) should suffice. It would also be helpful if you stated how you calculated the areas. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/