persp and trans3d for type="h" points
You are drawing the line to the center of the plot (which is 0 be design). What you actually want is to plot segments to the min(z) value. Example: Z <- matrix(1:9, 3) surf <- persp(1:3, 1:3, Z) points(trans3d(x=2, y=2, z=5, surf), col="red", pch=19) from <- trans3d(x=2, y=2, z=5, surf) to <- trans3d(x=2, y=2, z=min(Z), surf) segments(from$x, from$y, to$x, to$y, col="red", lwd=2) Uwe Ligges
On 13.06.2011 22:01, Tarmo Remmel wrote:
Hello, I have a matrix [9,11] called tempmed from which I produce a perspective plot. I then indicate a point on the surface to which I want to drop a point using points() and trans3d(). The code is below. However, the dropped line does not draw properly on the plot, it only comes down about half way through the vertical space. Is there a way to make this dropped line from a point hit the surface, or at least draw to the bottom of the plot? Using R 2.12.1 for PC. Thanks, Tarmo
tempmed
[,1] [,2] [,3] [,4] [,5]
[1,] 0.001953125 0.001953125 0.001953125 0.001953125 0.002197266
[2,] 0.005371094 0.005371094 0.005615234 0.005615234 0.006103516
[3,] 0.018798828 0.019042969 0.019042969 0.019775391 0.020019531
[4,] 0.160522461 0.155517578 0.147460938 0.137695312 0.131225586
[5,] 0.484130859 0.482421875 0.480712891 0.479003906 0.475463867
[6,] 0.598144531 0.597656250 0.597412109 0.597167969 0.596923828
[7,] 0.699707031 0.699707031 0.699707031 0.699462891 0.699462891
[8,] 0.800048828 0.800048828 0.800048828 0.800048828 0.800048828
[9,] 0.899902344 0.899902344 0.899902344 0.899902344 0.899902344
[,6] [,7] [,8] [,9] [,10]
[1,] 0.002197266 0.002441406 0.002685547 0.003173828 0.004150391
[2,] 0.006347656 0.006835938 0.007568359 0.009033203 0.011596680
[3,] 0.020996094 0.021972656 0.023925781 0.026611328 0.033935547
[4,] 0.127319336 0.125610352 0.121459961 0.119140625 0.129638672
[5,] 0.471557617 0.469482422 0.464355469 0.455200195 0.443115234
[6,] 0.595947266 0.595458984 0.594238281 0.592285156 0.589843750
[7,] 0.699462891 0.699218750 0.698974609 0.698486328 0.697631836
[8,] 0.800048828 0.800048828 0.800048828 0.799804688 0.799560547
[9,] 0.899902344 0.899902344 0.899902344 0.899902344 0.899902344
[,11]
[1,] 0.01855469
[2,] 0.05310059
[3,] 0.11010742
[4,] 0.21472168
[5,] 0.39318848
[6,] 0.56079102
[7,] 0.68554688
[8,] 0.79589844
[9,] 0.89916992
persp(tempmed, ticktype="detailed", cex.axis=0.7, zlab="Metric",
ylab="Proportion", xlab="Rho", theta=-45)
surf<- persp(tempmed, ticktype="detailed", cex.axis=0.7, zlab="Metric",
ylab="Proportion", xlab="Rho", theta=-45)
points(trans3d(x=0.2, y=0.7, z=max(tempmed), surf), col="red", pch=19,
type="b")
points(trans3d(x=0.2, y=0.7, z=max(tempmed), surf), col="red", pch=19,
type="h")
_____________________________________ Tarmo K Remmel PhD Associate Professor, Department of Geography York University, N413A Ross Building 4700 Keele Street, Toronto, Ontario, M3J 1P3 Tel: 416-736-2100 x22496, Fax: 416-736-5988 Skype: tarmoremmel ______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.