Correct scaling of axis in persp3d plot
I uploaded the data here: http://uploadeasy.net/upload/p4d81.rar As I said, I know my color example is wrong, that's why I am looking for a correct solution, also, I would be interested in how I can get a better axis, as I described the problem. Thanks a lot for your help, Ivanov ----- Urspr?ngliche Message ----- Von: David Winsemius <dwinsemius at comcast.net> An: Ivanov Ruporvrich <ivanovruporvrich at yahoo.com> CC: "r-help at r-project.org" <r-help at r-project.org> Gesendet: 0:23 Mittwoch, 26.Juni 2013 Betreff: Re: [R] Correct scaling of axis in persp3d plot
On Jun 25, 2013, at 12:40 PM, Ivanov Ruporvrich wrote:
Hi, I want to format my axis in my persp3d plot. With my data, which I attached
You may have attached it ... but you probably didn't read the information about what would be accepted by the mail server. Read the listinfo page linked at the bottom of every posting to Rhelp.
I created a persp3d plot with the following code, which I summarized from different code snippets I found: library(rugarch)library(rgl)library(fGarch)
fd <-as.data.frame(modelfit,which ='density')
Missing <CR>'s added to note that 'modelfit' was never created by the code posted to R-help.
color <-rgb(85,141,85,maxColorValue=255)x <-seq(-0.2,0.2,length=100)y <-c(1:2318)f <-function(s,t){dged(s,mean=fd[t,'Mu'],sd=fd[t,'Sigma'],nu=fd[t,'Shape'])}z <-outer(x,y,f)persp3d(x,y,z,theta=50,phi=25,expand=0.75,col=color,ticktype="detailed",xlab="",ylab="time",zlab="",axes=TRUE,axes=FALSE)
Missing carriage returns are probably inhibiting people from reading this.
axes3d(c('x--','z'))axis3d(edge='y+-',at =seq(500,2000,by=500),labels =rownames(fd)[seq(500,2000,by=500)])
My first question is:
Currently I have four date ticks on my axis, but what I don't like is, that in my data,
the starting date is in 2004, but the plots look like, as if the starting year
would be 2006. So I would like to have the starting year on the axis, but I don't
know how to implement this (my R programming skills are limited)?
So e.g. I would like to have always the beginning of each year, 2004, 2005, 2006, 2007, 2008,
2009, 2010, 2011 , 2012 or if this does not fit at leas I would like to
have the beginning of the years 2004,2006,2008,2010,2012 so each second year.
My second question is:
I would like to have a colored surface. So I would like to have e.g. the spikes of the surface in red (values
which are very larger) and lower values e.g. in green with a nice smooth transition between, e.g.
values in the middle in yellow. So the coloring should depend on the z values. I tried the following, but it does not
give nice results:
nrz <- nrow(z)
ncz <- ncol(z)
jet.colors <-
If you wanted a transition from red to green, then why use those values that go from pale red to dark red? Shouldn't it be:
mycols <- colorRampPalette( c("#ff0000", "#00ff00") )
Or:
mycols <- colorRampPalette( c("#00ff00", "#ff0000") )
# Generate the desired number of colors from this palette nbcol <- 100 color <- jet.colors(nbcol) # Compute the z-value at the facet centres zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
That looks wrong. Appears you are using code from the example in ?persp rather than using the z values appropriate to persp3d.
# Recode facet z-values into color indices facetcol <- cut(zfacet, nbcol) persp3d(x, y, z, theta=50, phi=25, expand=0.75, col=color[facetcol], ticktype="detailed", xlab="", ylab="time", zlab="",axes=TRUE) Thanks a lot for your help, Ivanov
______________________________________________ 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.
David Winsemius Alameda, CA, USA