alternative to wireframe()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

alternative to wireframe()

Rainer Krug-3
Hi

I am slowly getting enough of wireframe() from the package lattice, as
it is to complicated for what I need and does not really do what I
want. I am using it to produce a (surprise!) wireframe plot (see example
below).
The plot function is part of plot.tss in a package which I am working
on, and the plot looks nice, but I would like to have the option to use
it as part of a layout(), which does not work.

Also, I did not get a real handle if I have to wrap the wireframe
function into a print().

So I am looking for a simpler alternative, which produces a similar plot
to the one created by the example below. I would prefer a different
legend and I would like to have the 3D plot respect the layout() command
above.

Any suggestions which function I could use?

Thanks,

Rainer


--8<---------------cut here---------------start------------->8---
library(lattice)
x <- structure(list(threshold1 = c(21, 74.5, 128, 181.5, 235, 21,
74.5, 128, 181.5, 235, 21, 74.5, 128, 181.5, 235, 21, 74.5, 128,
181.5, 235, 21, 74.5, 128, 181.5, 235), threshold2 = c(0, 0,
0, 0, 0, 61.25, 61.25, 61.25, 61.25, 61.25, 122.5, 122.5, 122.5,
122.5, 122.5, 183.75, 183.75, 183.75, 183.75, 183.75, 245, 245,
245, 245, 245), overallAccuracy = c(0.606076276664512, 0.606076276664512,
0.606076276664512, 0.606076276664512, 0.606076276664512, 0.594182288299935,
0.597026502908856, 0.605559146735617, 0.606076276664512, 0.606076276664512,
0.6120232708468, 0.62262443438914, 0.633742727860375, 0.611376858435682,
0.606076276664512, 0.618616677440207, 0.630122818358112, 0.706658047834518,
0.695151906916613, 0.606076276664512, 0.393923723335488, 0.405429864253394,
0.482740788623142, 0.58655462184874, 0.606076276664512), sensitivity = c(0,
0, 0, 0, 0, 0.012471283229406, 0.0118148999015425, 0.00393829996718083,
0, 0, 0.130620282244831, 0.126025598949787, 0.0912372825730226,
0.0141122415490647, 0, 0.598949786675418, 0.594355103380374,
0.526419428946505, 0.296685264194289, 0, 1, 0.995405316704956,
0.927469642271086, 0.661962586150312, 0), specificity = c(1,
1, 1, 1, 1, 0.972269624573379, 0.977389078498293, 0.996587030716723,
1, 1, 0.924914675767918, 0.945392491467577, 0.986348122866894,
0.99957337883959, 1, 0.631399317406143, 0.653370307167236, 0.823805460750853,
0.954138225255973, 1, 0, 0.0219709897610922, 0.193686006825939,
0.537542662116041, 1), tss = c(0, 0, 0, 0, 0, -0.0152590921972152,
-0.010796021600164, 0.000525330683904368, 0, 0, 0.0555349580127491,
0.0714180904173634, 0.0775854054399168, 0.0136856203886551, 0,
0.230349104081562, 0.24772541054761, 0.350224889697358, 0.250823489450262,
0, 0, 0.0173763064660479, 0.121155649097025, 0.199505248266353,
0), kappa = c(0, 0, 0, 0, 0, -0.0182824920390604, -0.0129583064846108,
0.000635541910639162, 0, 0, 0.0639760122213153, 0.0828765513813943,
0.0918579943188013, 0.0165372451769894, 0, 0.223843122923358,
0.242311121014362, 0.363093208690974, 0.28206036774748, 0, 0,
0.0137627491763651, 0.100591615720438, 0.187264280971332, 0),
    pP = c(0L, 0L, 0L, 0L, 0L, 38L, 36L, 12L, 0L, 0L, 398L, 384L,
    278L, 43L, 0L, 1825L, 1811L, 1604L, 904L, 0L, 3047L, 3033L,
    2826L, 2017L, 0L), pA = c(0L, 0L, 0L, 0L, 0L, 130L, 106L,
    16L, 0L, 0L, 352L, 256L, 64L, 2L, 0L, 1728L, 1625L, 826L,
    215L, 0L, 4688L, 4585L, 3780L, 2168L, 0L), aA = c(4688L,
    4688L, 4688L, 4688L, 4688L, 4558L, 4582L, 4672L, 4688L, 4688L,
    4336L, 4432L, 4624L, 4686L, 4688L, 2960L, 3063L, 3862L, 4473L,
    4688L, 0L, 103L, 908L, 2520L, 4688L), aP = c(3047L, 3047L,
    3047L, 3047L, 3047L, 3009L, 3011L, 3035L, 3047L, 3047L, 2649L,
    2663L, 2769L, 3004L, 3047L, 1222L, 1236L, 1443L, 2143L, 3047L,
    0L, 14L, 221L, 1030L, 3047L), n = 7735L), .Names = c("threshold1",
"threshold2", "overallAccuracy", "sensitivity", "specificity",
"tss", "kappa", "pP", "pA", "aA", "aP", "n"), class = "TSS", link = .Primitive("&"), largerPres1 = TRUE, largerPres2 = FALSE, threshold1 = c(21,
74.5, 128, 181.5, 235), threshold2 = c(0, 61.25, 122.5, 183.75,
245), dimension = 2)

columns <- c("tss", "sensitivity", "specificity")
column.col <- rainbow(length(columns))
xp <- rep(x$threshold1, length(columns))
yp <- rep(x$threshold2, length(columns))
zp <- NULL
for (i in 1:length(columns)) {
    zp <- c(zp, x[[columns[i]]])
}

grp <- rep(columns, each=length(x$tss))

#######
layout(matrix(1:4, ncol=2), c(1,2,3,4))
#######

wireframe(
    zp ~ xp * yp,
    xlab = "threshold 1",
    ylab = "threshold 2",
    zlab = paste(columns, collapse="\n"),
    groups = grp,
    par.settings = simpleTheme(
        alpha = 0.7,
        col = column.col,
        ),
    scales = list(arrows = FALSE),
    auto.key = TRUE
    )
--8<---------------cut here---------------end--------------->8---

--
Rainer M. Krug

email: RMKrug<at>gmail<dot>com

______________________________________________
[hidden email] 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.

attachment0 (504 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: alternative to wireframe()

MacQueen, Don
Have you looked at persp() ?

--
Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062





On 3/4/14 2:56 AM, "Rainer M Krug" <[hidden email]> wrote:

>Hi
>
>I am slowly getting enough of wireframe() from the package lattice, as
>it is to complicated for what I need and does not really do what I
>want. I am using it to produce a (surprise!) wireframe plot (see example
>below).
>The plot function is part of plot.tss in a package which I am working
>on, and the plot looks nice, but I would like to have the option to use
>it as part of a layout(), which does not work.
>
>Also, I did not get a real handle if I have to wrap the wireframe
>function into a print().
>
>So I am looking for a simpler alternative, which produces a similar plot
>to the one created by the example below. I would prefer a different
>legend and I would like to have the 3D plot respect the layout() command
>above.
>
>Any suggestions which function I could use?
>
>Thanks,
>
>Rainer
>
>
>--8<---------------cut here---------------start------------->8---
>library(lattice)
>x <- structure(list(threshold1 = c(21, 74.5, 128, 181.5, 235, 21,
>74.5, 128, 181.5, 235, 21, 74.5, 128, 181.5, 235, 21, 74.5, 128,
>181.5, 235, 21, 74.5, 128, 181.5, 235), threshold2 = c(0, 0,
>0, 0, 0, 61.25, 61.25, 61.25, 61.25, 61.25, 122.5, 122.5, 122.5,
>122.5, 122.5, 183.75, 183.75, 183.75, 183.75, 183.75, 245, 245,
>245, 245, 245), overallAccuracy = c(0.606076276664512, 0.606076276664512,
>0.606076276664512, 0.606076276664512, 0.606076276664512,
>0.594182288299935,
>0.597026502908856, 0.605559146735617, 0.606076276664512,
>0.606076276664512,
>0.6120232708468, 0.62262443438914, 0.633742727860375, 0.611376858435682,
>0.606076276664512, 0.618616677440207, 0.630122818358112,
>0.706658047834518,
>0.695151906916613, 0.606076276664512, 0.393923723335488,
>0.405429864253394,
>0.482740788623142, 0.58655462184874, 0.606076276664512), sensitivity =
>c(0,
>0, 0, 0, 0, 0.012471283229406, 0.0118148999015425, 0.00393829996718083,
>0, 0, 0.130620282244831, 0.126025598949787, 0.0912372825730226,
>0.0141122415490647, 0, 0.598949786675418, 0.594355103380374,
>0.526419428946505, 0.296685264194289, 0, 1, 0.995405316704956,
>0.927469642271086, 0.661962586150312, 0), specificity = c(1,
>1, 1, 1, 1, 0.972269624573379, 0.977389078498293, 0.996587030716723,
>1, 1, 0.924914675767918, 0.945392491467577, 0.986348122866894,
>0.99957337883959, 1, 0.631399317406143, 0.653370307167236,
>0.823805460750853,
>0.954138225255973, 1, 0, 0.0219709897610922, 0.193686006825939,
>0.537542662116041, 1), tss = c(0, 0, 0, 0, 0, -0.0152590921972152,
>-0.010796021600164, 0.000525330683904368, 0, 0, 0.0555349580127491,
>0.0714180904173634, 0.0775854054399168, 0.0136856203886551, 0,
>0.230349104081562, 0.24772541054761, 0.350224889697358,
>0.250823489450262,
>0, 0, 0.0173763064660479, 0.121155649097025, 0.199505248266353,
>0), kappa = c(0, 0, 0, 0, 0, -0.0182824920390604, -0.0129583064846108,
>0.000635541910639162, 0, 0, 0.0639760122213153, 0.0828765513813943,
>0.0918579943188013, 0.0165372451769894, 0, 0.223843122923358,
>0.242311121014362, 0.363093208690974, 0.28206036774748, 0, 0,
>0.0137627491763651, 0.100591615720438, 0.187264280971332, 0),
>    pP = c(0L, 0L, 0L, 0L, 0L, 38L, 36L, 12L, 0L, 0L, 398L, 384L,
>    278L, 43L, 0L, 1825L, 1811L, 1604L, 904L, 0L, 3047L, 3033L,
>    2826L, 2017L, 0L), pA = c(0L, 0L, 0L, 0L, 0L, 130L, 106L,
>    16L, 0L, 0L, 352L, 256L, 64L, 2L, 0L, 1728L, 1625L, 826L,
>    215L, 0L, 4688L, 4585L, 3780L, 2168L, 0L), aA = c(4688L,
>    4688L, 4688L, 4688L, 4688L, 4558L, 4582L, 4672L, 4688L, 4688L,
>    4336L, 4432L, 4624L, 4686L, 4688L, 2960L, 3063L, 3862L, 4473L,
>    4688L, 0L, 103L, 908L, 2520L, 4688L), aP = c(3047L, 3047L,
>    3047L, 3047L, 3047L, 3009L, 3011L, 3035L, 3047L, 3047L, 2649L,
>    2663L, 2769L, 3004L, 3047L, 1222L, 1236L, 1443L, 2143L, 3047L,
>    0L, 14L, 221L, 1030L, 3047L), n = 7735L), .Names = c("threshold1",
>"threshold2", "overallAccuracy", "sensitivity", "specificity",
>"tss", "kappa", "pP", "pA", "aA", "aP", "n"), class = "TSS", link =
>.Primitive("&"), largerPres1 = TRUE, largerPres2 = FALSE, threshold1 =
>c(21,
>74.5, 128, 181.5, 235), threshold2 = c(0, 61.25, 122.5, 183.75,
>245), dimension = 2)
>
>columns <- c("tss", "sensitivity", "specificity")
>column.col <- rainbow(length(columns))
>xp <- rep(x$threshold1, length(columns))
>yp <- rep(x$threshold2, length(columns))
>zp <- NULL
>for (i in 1:length(columns)) {
>    zp <- c(zp, x[[columns[i]]])
>}
>
>grp <- rep(columns, each=length(x$tss))
>
>#######
>layout(matrix(1:4, ncol=2), c(1,2,3,4))
>#######
>
>wireframe(
>    zp ~ xp * yp,
>    xlab = "threshold 1",
>    ylab = "threshold 2",
>    zlab = paste(columns, collapse="\n"),
>    groups = grp,
>    par.settings = simpleTheme(
>        alpha = 0.7,
>        col = column.col,
>        ),
>    scales = list(arrows = FALSE),
>    auto.key = TRUE
>    )
>--8<---------------cut here---------------end--------------->8---
>
>--
>Rainer M. Krug
>
>email: RMKrug<at>gmail<dot>com

______________________________________________
[hidden email] 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.