MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Coloring a ListSurfacePlot3D with a n x 4 matrix

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118274] Re: Coloring a ListSurfacePlot3D with a n x 4 matrix
  • From: David Kahle <david.kahle at gmail.com>
  • Date: Tue, 19 Apr 2011 06:58:17 -0400 (EDT)

Hi Bob!

Thanks for the reply.

Unfortunately, since I only have the points in the matrix I don't know  
what the underlying function is.  I tried to get around the problem  
with Interpolation, but Interpolation (for some reason) wasn't able to  
make a function that I could then pass to ListSurfacePlot3D.  So I  
tried with BSplineFunction, but that didn't work either but for a  
different reason (mis-specification problem?).

Ideas?  Code below.

Thanks again
david.



points = Flatten[
    Table[{x, y, 1 - x - y, (x - 1/2)^2 + (y - 1/2)^2 + RandomReal[]},  
{x, 0,
      1, 1/4}, {y, 0, 1, 1/4}], 1];

knots = Most /@ points;

values = Last /@ points;

list4interpolation = Table[{knots[[k]], values[[k]]}, {k,  
Length[knots]}];

intF = Interpolation[list4interpolation] (* fails *)



f = BSplineFunction[points];

colorF = Function[{x, y, z}, ColorData["GreenBrownTerrain"]@f[x, y, z]];

ListSurfacePlot3D[knots, ColorFunction -> colorF]


On Apr 18, 2011, at 5:37 AM, Bob Hanlon wrote:

>
> The ColorFunction must be defined for all values of {x,y,z} not just  
> discrete values.
>
> points = Flatten[Table[
>    {x, y, 1 - x - y, (x - 1/2)^2 + (y - 1/2)^2},
>    {x, 0, 1, 1/4}, {y, 0, 1, 1/4}], 1];
>
> knots = Most /@ points;
>
> colorF = Function[{x, y, z},
>   ColorData["GreenBrownTerrain"][
>    (x - 1/2)^2 + (y - 1/2)^2]];
>
> ListSurfacePlot3D[knots, ColorFunction -> colorF]
>
>
> Bob Hanlon
>
> ---- David Kahle <david.kahle at gmail.com> wrote:
>
> =============
> Hi all -
>
> I have a matrix whose rows, 4 dimensional vectors, represent (x, y, z)
> values as well as a measurement f which I would like to use to create
> an interpolated surface colored according to the value of f.
> ListSurfacePlot3D gives me the appropriate surface (when I strain out
> the x, y, z values), but I'm having a hard time coloring it.  I've
> tried basic stuff with ColorFunction to no avail, but I'm sure this is
> a simple task.  Ideas?  Small example below.
>
>
> Points = Flatten[
>    Table[{x, y, 1 - x - y, (x - 1/2)^2 + (y - 1/2)^2}, {x, 0, 1,
> 1/4}, {y, 0,
>      1, 1/4}], 1];
> N[Points[[1 ;; 5]]]
>
> Knots = Map[Take[#, {1, 3}] &, Points];
> N[Knots[[1 ;; 5]]]
>
> ListSurfacePlot3D[Knots] (* Works fine, how to I color the surface? *)
>
> Colorf = Function[{x, y, z},  ColorData["GreenBrownTerrain"][
>     Points[[ Position[Knots, {x, y, z}][[1]] ]][[1]][[4]]
> ]];
> ListSurfacePlot3D[Knots, ColorFunction -> Colorf]
>
>
> Many thanks
> david.
>
> ----------------------------------
> ----------------------------------
> David Kahle
> Rice University
> Rm. 1041 Duncan Hall
> Department of Statistics, MS 138
> 6100 Main St.
> Houston, TX 77005
> http://sites.google.com/site/davidkahle
>
>



  • Prev by Date: Re: trouble printing to PDF
  • Next by Date: Re: trouble printing to PDF
  • Previous by thread: Re: Coloring a ListSurfacePlot3D with a n x 4 matrix
  • Next by thread: Re: Coloring a ListSurfacePlot3D with a n x 4 matrix