Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15148

color surface according to absolut value of the gradient

From conrad.clausz@gmail.com
Newsgroups comp.soft-sys.math.mathematica
Subject color surface according to absolut value of the gradient
Date 2013-07-08 08:22 +0000
Message-ID <krdsri$gti$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


I have a set of data, let's say

data = Flatten[
   Table[{i, j, 
     Sin[i] Cos[
       j]}, {i, -\[Pi], \[Pi], .25}, {j, -\[Pi], \[Pi], .25}], 1];

If I plot this, everything is fine. To get the derivatives I interpolated the set of data

f = Interpolation[data];

If I then plot the absolute value of the gradient in the same range it also looks correct.

ListPlot3D[
 Flatten[Table[{i, j, 
    Sqrt[D[f[x, y], x]^2 + D[f[x, y], y]^2] /. {x -> i, 
      y -> j}}, {i, -\[Pi], \[Pi], .25}, {j, -\[Pi], \[Pi], .25}], 1]]

Now I want to plot the original data with the surface colored according to the values of the last plot. I tried

ListPlot3D[data, 
 ColorFunction -> (ColorData["Rainbow"][
     Sqrt[D[f[x, #2], x]^2 + D[f[#1, y], y]^2] /. {x -> #1, 
       y -> #2}] &)]

but the result is definitely off. What am I making wrong?

Thanks in advance,
Conrad

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

color surface according to absolut value of the gradient conrad.clausz@gmail.com - 2013-07-08 08:22 +0000

csiph-web