[R] How to add circular text for a graph with concentric circles
sparandekar at worldbank.org
sparandekar at worldbank.org
Tue Jul 24 21:40:26 CEST 2007
Dear R experts,
I am plotting the population of students who live in a city, and in
successive circular bands made of the contiguous districts that surround
the city. This is a stylized figure, where I specify the area of each
successive circle based on the cumulative population of students. I want
to compare two sets of concentric circles across different populations -
such as 'All students' and 'Private students' (those attending private
school) by using the same colours and the same dimension of the outer
circle. I have attached the .pdf file with the output, and the R code to
generate the first set of circles.
I would appreciate any tips about how to rotate the text label that marks
each concentric circle (except the central circle) to be curved around the
circle, located in the middle of each band, thus following the circle
instead of being horizontal, as I have it now.
Thank you very much,
best regards,
Suhas
# Conurbano1a.R
# R Program to generate circles, radii based on proportion of ALL STUDENTS
# Prepared by Suhas, Tuesday, July 24, 2007
grid.circle(x=0.5, y=0.5, r=3*(.1268), default.units="npc", name=NULL,
gp=gpar(fill="olivedrab1",col=NULL), draw=TRUE, vp=NULL)
grid.circle(x=0.5, y=0.5, r=3*(0.095882), default.units="npc", name=NULL,
gp=gpar(fill="cornflowerblue",col=NULL), draw=TRUE,
vp=NULL)
grid.circle(x=0.5, y=0.5, r=3*(0.077894), default.units="npc", name=NULL,
gp=gpar(fill="aliceblue",col=NULL), draw=TRUE, vp=NULL)
grid.circle(x=0.5, y=0.5, r=3*(0.061884), default.units="npc", name=NULL,
gp=gpar(fill="seagreen",col=NULL), draw=TRUE, vp=NULL)
grid.circle(x=0.5, y=0.5, r=3*(0.050740), default.units="npc", name=NULL,
gp=gpar(fill="lightpink2",col=NULL), draw=TRUE, vp=NULL)
grid.circle(x=0.5, y=0.5, r=3*(0.045906), default.units="npc", name=NULL,
gp=gpar(fill="navy",col=NULL), draw=TRUE, vp=NULL)
# Now to add the labels ? used trial and error for x and y values
grid.text("Provincia Interior", x=0.5, y=0.85,
gp=gpar(fontsize=6, col="black"))
grid.text("Conurbano 4", x=0.5, y=0.75,
gp=gpar(fontsize=6, col="black"))
grid.text("Conurbano 3", x=0.5, y=0.71,
gp=gpar(fontsize=6, col="black"))
grid.text("Conurbano 2", x=0.5, y=0.67,
gp=gpar(fontsize=6, col="white"))
grid.text("Conurbano 1", x=0.5, y=0.645,
gp=gpar(fontsize=6, col="black"))
grid.text("Ciudad de Buenos Aires", x=0.5, y=0.56,
gp=gpar(fontsize=6, col="white"))
# Title of graph
grid.text("All Students", x=0.2,y=0.95,gp=gpar(fontsize=20,col="navy"))
**************************************************************************
Suhas D. Parandekar
Senior Education Economist
Latin American and Caribbean Region
Tel: 202 458 7622
e-mail: sparandekar at worldbank.org
More information about the R-help
mailing list