[R] coloring wireframe plot with independent/separate matrix of color values.

ilai keren at math.montana.edu
Thu Mar 15 18:00:13 CET 2012


On Wed, Mar 14, 2012 at 9:47 PM, Alex Miller <alexjcmiller at gmail.com> wrote:
> Dear R Users,
>
> I am trying to plot a matrix (a Digital Elevation Model) using wireframe
> [lattice] and color that matrix based on a separate/independent matrix of
> the same resolution

This makes no sense. the values in DEM are the z-coords of corners,
not centroids of the facet. A matrix of colors of the same dimensions
is not going to work as col.regions

 cloud(outer(1:3,1:3),par.box=list(col=NA),type='p',col=1:9)
 wireframe(outer(1:3,1:3)) # 1:9 makes no sense.

I don't know of an easy way to drape color by something other than the
default "height".  You could maybe modify the shade.colors.palette
function so it returns the colors in your temp matrix.  More details
in ?panel.3dwire

Best,


(both have the same number of rows and columns) as the
> DEM.  More specifically I would like to plot a DEM using wireframe and
> color each cell/tile based on interpolated surface temperature
> measurements.  Within the wireframe function, the arguments
> "color.regions", "drape" and "at" seemed most important to accomplish
> this.  However, I have not been successful.  Below is another explanation
> with some example data.
>
> ###
>
> #say we have a matrix
>
> DEM=matrix(1:100, ncol=10)
>
> #we also have a matrix of interpolated temperatures measurements (or any
> other kind of data with the same resolution as the DEM)
>
> interpTEMP = matrix(floor(runif(100, 1,10)),ncol=10)
>
> #I would normally go through and apply a function to use html color codes
> to coincide with interpTEMP but these values will prove my dilemma.
>
> #now I would like to plot my DEM and color each cell based on the
> "matching" cell of interpTEMP
> #N.B. that this obviously isn't the correct way of doing things as it
> doesn't work!
>
> wireframe(x=DEM, drape=TRUE, col.regions=as.vector(interpTEMP))
>
> ###
>
> any ideas on how to combat this problem?  Please let me know if I need to
> be more clear or provide additional information.  Many blessings for your
> help!
>
> .alex
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.



More information about the R-help mailing list