1
$\begingroup$

In this document http://pastebin.com/XEyrDHyB the first 2 coloums are the position and the third the value of the fuction.

I need to create a 2d image where in each position the value of the function is represented by a color. The highest value would have a different colour from the lowest. It would be great if the areas where the values of the function are similar are marked.

$\endgroup$
6
$\begingroup$

Here's a few ways to visualize the data:

I've imported your data as a 524 by 3 matrix:

Dimensions[data]
{524, 3}

The easiest way is with ListDensityPlot:

ListDensityPlot[data, ColorFunction -> Hue]

enter image description here

For the other methods, I rescale the function values to run from 0 to 1:

data[[All, 3]] = Rescale[data[[All, 3]]];

A different approach is to use Graphics:

Graphics[
 {Hue[#3], {Hue[#3], Cuboid[{#1, #2} - 0.015, {#1, #2} + 0.015]}} & @@@ data, 
 Frame -> True
]

enter image description here

Another is with ListPlot:

ListPlot[
 Style[{#1, #2}, Hue[#3]] & @@@ data,
 PlotStyle -> PointSize[0.03],
 AspectRatio -> Automatic,
 Axes -> False,
 Frame -> True
]

enter image description here


As for marking similar values, you can use ClusterClassify. Here I partition into 4 groups:

c = ClusterClassify[data, 4];

Do[color[j] = RandomColor[], {j, 1, 4}]

Graphics[{color[#3], Cuboid[{#1, #2} - 0.015, {#1, #2} + 0.015]} & @@@ 
  Map[Append[Most[#], c[#]] &, data], Frame -> True]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.