KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have the following 3d plot: With my data I created it with the following code: library(rugarch) library(rgl) library(fGarch) fd <- as.data.frame(modelfit, which = 'density') 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) How can I get a coloring depending on the z values? I looked at different solutions, e.g. this one , but I could not create the coloring depending on the z values in this case. The solution according to this thread would be the following: nrz <- nrow(z) ncz <- ncol(z) jet.colors <- colorRampPalette( c("#ffcccc", "#cc0000") ) # 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] # 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) But this does not give a good result, since it does not color the plot appropriate. I want to have the spikes of my surface to be e.g. in red and the low values to be e.g. in blue with a nice smooth transition, but this kind of colors the slices, so depending on the time
Tags (comma-separated)
Save Edits
Cancel