R轴图上的实际数据

时间:2018-05-24 09:08:20

标签: r lattice

我会R在轴上打印实际数据。正如您所看到的,$ \ beta $在x轴上从-0.5到0.5,但是R绘制了点数。

library(lattice)
T <- 40
r <- 0.02
sigma <- 0.1
w <- 100
w0 <- 20
P <- 1.0
gamm <- 0.05

t <- 30

sb <- 0.10
prop <- function(beta, mu){
  (mu - r) * (w - w0 - T) * exp(-r * (T - t)) * 
    (mu - (mu - r) *  exp(-2 * beta * r * (T - t))) / 
    (gamm * r * sigma^2 * sb * (w - w0 - t))
}

beta <- seq(-0.5, 0.5, length= 10)
mu <- seq(0.04, 0.09, length= 10)

z <- outer(beta, mu, prop)

#this removes a border from the fig
trellis.par.set("axis.line", list(col="transparent"))

wireframe(z, drape=TRUE, xlab = expression(paste(beta)), ylab=expression(mu),
          zlab=expression(pi(t)), scale=list(arrows=FALSE))

1 个答案:

答案 0 :(得分:2)

您可以为矩阵z指定rownames和colnames - 这将更改沿轴显示的内容:

z <- outer(beta, mu, prop)
rownames(z) <- round(beta, digits=2)
colnames(z) <- round(mu, digits=2)

#this removes a border from the fig
trellis.par.set("axis.line", list(col="transparent"))

wireframe(z, drape=TRUE, xlab = expression(paste(beta)), ylab=expression(mu),
          zlab=expression(pi(t)), scale=list(arrows=FALSE))

enter image description here