投标租金曲线 - 从另一个维度绘制投影半径的圆

Bid Rent Curves - Plotting Circles of Projected Radii from Another Dimension

目标是在 R 中重现此 Bid-Rent 图:

挑战在于绘制投影的圆圈。到目前为止我得到了:

二维部分是用下面的R代码用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 from 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")
  1. (详情:为什么曲线不符合 ylim = 0 ?)
  2. 如何投影和画半圆?

这不完全是 3D 情节。我研究过 plot3D 和 rgl。我不确定从这里使用哪个包或策略。

我相信你想要圆圈,所以你需要将绘图区域推到右上角:

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 for y
           xlim =c(0,7 ), ylim=c(0,10), col=colr,  # need xlim and ylim to match base plot ranges
           yaxs="i", yaxt="n", xaxs="i") # yaxis off; x and y axes meet at origin
  par(opar)}

然后将绘图向上和向右推:这将在 y=0 线下方绘制一个彩色半圆(最大的在前,因此它们重叠)。

png()  # send to image file;  not needed for testing
opar <- par(mar=c(15, 15, 2,2) ) # default units are in widths of text-"line".
# the margins start at lower, then clockwise

# run your code

outHalfCirc(5.5, "blue")
outHalfCirc(2.5, "red")
outHalfCirc(1, "green")
dev.off()  # complete image production
par(opar)  # different than the 'opar' inside the function

瞧!虽然不是真正的圆圈,因为纵横比不是 1。这可以固定(或者您可以将 xlim 和 ylim 设置为相等。