r - Bid Rent Curves - Plotting Circles of Projected Radii from Another Dimension -
the goal reproduce bid-rent graph in r:
the challenge draw projected circles. far got:
the 2d part created r code below traditional graphic system in base r:
#distance x <- seq(0,7,1) #bid rent curves: commercial, industrial, residential com <- -5*x + 10 ind <- -2*x + 7 res <- -0.75*x + 4 graph <- plot(x, com, type="l", col="green", ylim=c(0,10), xlab="", ylab="", axes=false) lines(x, ind, col="red") lines(x, res, col="blue") abline(v=0, h=0) segments(1,0, 1,5, lty=2) segments(2.5,0, 2.5,2, lty=2) title(main="bid rent curves", sub="alonso model", xlab="distance cbd", ylab="rent per m2") text(2.5,7.5, "commercial", col="green") text(3.5,4, "industrial", col="red") text(5.5,2, "residential", col="blue")
- (detail: why curves not respect ylim = 0 ?)
- how make projection , draw semi-circles?
it not 3d plot. have looked plot3d , rgl. not sure packages or strategy use here.
i'm taking @ word want circles, need push plot area upper right corner:
outhalfcirc <- function(r,colr) {opar=par(xpd=true, new=true) #plot ouside plot area polygon(x=seq(r,-r,by=-0.1), y= -sqrt(r^2 - seq(r,-r,by=-0.1)^2) , # solve r^2 = x^2 +y^2 y xlim =c(0,7 ), ylim=c(0,10), col=colr, # need xlim , ylim match base plot ranges yaxs="i", yaxt="n", xaxs="i") # yaxis off; x , y axes meet @ origin par(opar)}
then push plot , right: draw colored half-circles (largest first overlap) below y=0 line.
png() # send image file; not needed testing opar <- par(mar=c(15, 15, 2,2) ) # default units in widths of text-"line". # margins start @ lower, clockwise # run code outhalfcirc(5.5, "blue") outhalfcirc(2.5, "red") outhalfcirc(1, "green") dev.off() # complete image production par(opar) # different 'opar' inside function
voila! although not circles because aspect ratio not 1. can fixed (or set xlim , ylim equal.
Comments
Post a Comment