require(graphics)
### FUNCTIONS kashp, dkashp_dx, ashp
xx <- (-3:3)*3
x <- (-9:9) ; names(x) <- x
k <- c(9999, 8, 5, 3, 2, 1) ; names(k) <- k
mat1 <- outer(x, k, kashp) ; mat1
mat2 <- outer(x, k,dkashp_dx) ; mat2
mat3 <- outer(x, k, ashp) ; mat3
### GRAPHICS
op <- par(mfcol = c(2,2), mar = c(3,3,2,1))
matplot(x, mat1, type="l", lwd=2, xaxt="n", yaxt="n", main="kashp")
axis(1, at = xx) ; axis(2, at = xx, las = 1)
legend("topleft", title = expression(kappa), legend = colnames(mat1),
lty = 1:6, col = 1:6, lwd = 2, inset = 0.02, cex = 0.7)
matplot(x, mat2, type="l", lwd=2, xaxt="n", main="dkashp_dx", las=1, ylim=c(0,1))
axis(1, at = xx)
legend("bottom", title = expression(kappa), legend = colnames(mat1),
lty = 1:6, col = 1:6, lwd = 2, inset = 0.02, cex = 0.7)
matplot(x, mat3, type="l", lwd=2, xaxt="n", main="ashp", las=1)
axis(1, at = xx)
legend("topleft", title = expression(kappa), legend = colnames(mat1),
lty = 1:6, col = 1:6, lwd = 2, inset = 0.02, cex = 0.7)
par(op)
Run the code above in your browser using DataLab