Awesome, thanks! On Mon, Aug 6, 2018 at 2:54 AM Paul Murrell <p...@stat.auckland.ac.nz> wrote:
> Hi > > Not in the persp() function itself, but the following code converts the > persp() output to 'grid' output then modifies the labels to add > percentage signs ... > > x <- seq(-10, 10, length= 30) > y <- x > f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r } > z <- outer(x, y, f) > z[is.na(z)] <- 1 > op <- par(bg = "white") > persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue", > ticktype = "detailed") > > library(gridGraphics) > grid.echo() > labelGrobs <- grid.grep("z-axis-labels", grep=TRUE, global=TRUE) > addPercent <- function(x) { > lab <- grid.get(x) > grid.edit(x, label=paste0(lab$label, "%"), redraw=FALSE) > } > lapply(labelGrobs, addPercent) > grid.refresh() > > ... is that what you meant? The positioning of the labels relative to > the tick marks is imperfect and could perhaps be improved by also > editing the 'cex' for the labels, but hopefully this gets close enough > to be useful. > > Paul > > On 06/08/18 01:04, Christofer Bogaso wrote: > > Hi, > > > > Is there any way to add styles to the tick marks in persp() function? > > > > For eample I want to add '%' suffix to the z-axis tick marks.in below > plot : > > > > x <- seq(-10, 10, length= 30) > > y <- x > > f <- function(x, y) { r <- sqrt(x^2+y^2); 10 * sin(r)/r } > > z <- outer(x, y, f) > > z[is.na(z)] <- 1 > > op <- par(bg = "white") > > persp(x, y, z, theta = 30, phi = 30, expand = 0.5, col = "lightblue", > > ticktype = "detailed") > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > > 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. > > > > -- > Dr Paul Murrell > Department of Statistics > The University of Auckland > Private Bag 92019 > Auckland > New Zealand > 64 9 3737599 x85392 > p...@stat.auckland.ac.nz > http://www.stat.auckland.ac.nz/~paul/ > [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.