2
$\begingroup$

I have some 3d points with coordinates and a value assigned to each point. I want to plot the points and depending on the value use a different color.

I have tried to use the answer in ListPlot3D - How to make the Color depending on a second list, but Interpolation does not work.

Interpolation::udeg: Interpolation on unstructured grids is currently only supported for InterpolationOrder->1 ...
Interpolation::femimq: "The element mesh has insufficient quality ...
Interpolation::fememtlq: "The quality -1.8665289611526646`*^-14 of the underlying mesh is too low..."

Here is a sample of points like the ones i want to plot (with the same structure {{{x,y,z},value},...} I used while trying to interpolate):

data =  {{{710, 76.2867, 39.966}, -1.70615}, {{710, 40.2502, 
   73.2953}, -5.06218}, {{710, -9.21471, 
   82.1714}, -6.7294}, {{710, -55.6054, 
   63.633}, -6.15158}, {{710, -83.4447, 
   23.865}, -3.5215}, {{710, -83.4447, -23.865}, 
  0.283382}, {{710, -55.6054, -63.633}, 
  3.99366}, {{710, -9.21471, -82.1714}, 
  6.37148}, {{710, 40.2502, -73.2953}, 
  6.62355}, {{710, 76.2867, -39.966}, 
  4.66578}, {{720, 68.9417, 52.0067}, -1.63914}, {{720, 30.1636, 
   78.3901}, -4.60195}, {{720, -17.4658, 
   81.7705}, -6.19948}, {{720, -59.9699, 
   61.1558}, -5.96296}, {{720, -84.8763, 
   22.5954}, -3.96179}, {{720, -84.8763, -22.5954}, -0.783197}, \
{{720, -59.9699, -61.1558}, 2.64008}, {{720, -17.4658, -81.7705}, 
  5.3035}, {{720, 30.1636, -78.3901}, 
  6.4255}, {{720, 68.9417, -52.0067}, 
  5.67684}, {{730, 63.9679, 58.7083}, -1.52177}, {{730, 24.0419, 
   81.1198}, -4.46802}, {{730, -22.4026, 
   81.5373}, -6.17621}, {{730, -62.7731, 
   59.8475}, -6.1832}, {{730, -86.1239, 
   21.9312}, -4.48709}, {{730, -86.1239, -21.9312}, -1.54775}, {{730, \
-62.7731, -59.8475}, 1.83788}, {{730, -22.4026, -81.5373}, 
  4.75184}, {{730, 24.0419, -81.1198}, 
  6.40409}, {{730, 63.9679, -58.7083}, 
  6.34663}, {{740, 61.2769, 62.4556}, -1.49987}, {{740, 20.7044, 
   82.8065}, -4.47847}, {{740, -25.2379, 
   81.6812}, -6.26191}, {{740, -64.6346, 
   59.3714}, -6.38765}, {{740, -87.2679, 
   21.6633}, -4.82307}, {{740, -87.2679, -21.6633}, -1.97396}, {{740, \
-64.6346, -59.3714}, 1.42075}, {{740, -25.2379, -81.6812}, 
  4.48062}, {{740, 20.7044, -82.8065}, 
  6.41207}, {{740, 61.2769, -62.4556}, 
  6.71416}, {{750, 59.7262, 65.}, -1.54366}, {{750, 18.6359, 
   84.1306}, -4.53748}, {{750, -27.1527, 
   82.0514}, -6.34961}, {{750, -66.0958, 
   59.2865}, -6.52319}, {{750, -88.3759, 
   21.5753}, -5.01446}, {{750, -88.3759, -21.5753}, -2.20378}, {{750, \
-66.0958, -59.2865}, 1.20027}, {{750, -27.1527, -82.0514}, 
  4.33949}, {{750, 18.6359, -84.1306}, 
  6.42248}, {{750, 59.7262, -65.}, 
  6.92411}, {{760, 61.2449, 65.}, -1.72584}, {{760, 19.681, 
   84.8354}, -4.65037}, {{760, -26.8947, 
   83.0673}, -6.35623}, {{760, -66.6216, 
   60.1459}, -6.40902}, {{760, -89.3832, 
   21.9083}, -4.7953}, {{760, -89.3832, -21.9083}, -1.92601}, {{760, \
-66.6216, -60.1459}, 1.46819}, {{760, -26.8947, -83.0673}, 
  4.52296}, {{760, 19.681, -84.8354}, 6.46039}, {{760, 61.2449, -65.},
   6.78711}, {{770, 62.7788, 65.}, -1.89666}, {{770, 20.7417, 
   85.5551}, -4.76174}, {{770, -26.63, 
   84.1059}, -6.37081}, {{770, -67.1526, 
   61.0252}, -6.31001}, {{770, -90.404, 
   22.2492}, -4.59499}, {{770, -90.404, -22.2492}, -1.66684}, {{770, \
-67.1526, -61.0252}, 1.72133}, {{770, -26.63, -84.1059}, 
  4.69812}, {{770, 20.7417, -85.5551}, 6.4979}, {{770, 62.7788, -65.},
   6.65779}, {{780, 64.3267, 65.}, -2.05642}, {{780, 21.8171, 
   86.2893}, -4.87143}, {{780, -26.3591, 
   85.1668}, -6.39277}, {{780, -67.6891, 
   61.924}, -6.22532}, {{780, -91.4383, 
   22.5978}, -4.41255}, {{780, -91.4383, -22.5978}, -1.4253}, {{780, \
-67.6891, -61.924}, 1.96056}, {{780, -26.3591, -85.1668}, 
  4.86561}, {{780, 21.8171, -86.2893}, 
  6.53535}, {{780, 64.3267, -65.}, 
  6.53608}, {{790, 65.8877, 65.}, -2.20549}, {{790, 22.9061, 
   87.0374}, -4.9793}, {{790, -26.0827, 
   86.2491}, -6.42158}, {{790, -68.2312, 
   62.8416}, -6.15407}, {{790, -92.4859, 
   22.9538}, -4.24693}, {{790, -92.4859, -22.9538}, -1.20032}, {{790, \
-68.2312, -62.8416}, 2.18678}, {{790, -26.0827, -86.2491}, 
  5.0261}, {{790, 22.9061, -87.0374}, 6.57302}, {{790, 65.8877, -65.},
   6.42184}, {{800, 67.4603, 65.}, -2.34437}, {{800, 24.0077, 
   87.7988}, -5.08531}, {{800, -25.8012, 
   87.3517}, -6.45667}, {{800, -68.779, 
   63.7772}, -6.09537}, {{800, -93.5467, 
   23.3169}, -4.09705}, {{800, -93.5467, -23.3169}, -0.990801}, \
{{800, -68.779, -63.7772}, 2.40096}, {{800, -25.8012, -87.3517}, 
  5.18022}, {{800, 24.0077, -87.7988}, 
  6.61113}, {{800, 67.4603, -65.}, 
  6.31485}, {{810, 69.0434, 65.}, -2.47359}, {{810, 25.1207, 
   88.5725}, -5.18945}, {{810, -25.5155, 
   88.4737}, -6.49756}, {{810, -69.3327, 
   64.7299}, -6.04832}, {{810, -94.6203, 
   23.6868}, -3.96181}, {{810, -94.6203, -23.6868}, -0.795645}, \
{{810, -69.3327, -64.7299}, 2.604}, {{810, -25.5155, -88.4737}, 
  5.32856}, {{810, 25.1207, -88.5725}, 
  6.64988}, {{810, 69.0434, -65.}, 
  6.21484}, {{820, 70.6354, 65.}, -2.59374}, {{820, 26.2439, 
   89.3578}, -5.29172}, {{820, -25.2263, 
   89.6136}, -6.54373}, {{820, -69.8923, 
   65.6985}, -6.01208}, {{820, -95.7067, 
   24.063}, -3.84015}, {{820, -95.7067, -24.063}, -0.613773}, {{820, \
-69.8923, -65.6985}, 2.79682}, {{820, -25.2263, -89.6136}, 
  5.47171}, {{820, 26.2439, -89.3578}, 
  6.68942}, {{820, 70.6354, -65.}, 
  6.1215}, {{830, 72.2352, 65.}, -2.70539}, {{830, 27.376, 
   90.1535}, -5.39219}, {{830, -24.9342, 
   90.7701}, -6.59475}, {{830, -70.4581, 
   66.6819}, -5.98578}, {{830, -96.8055, 
   24.445}, -3.73102}, {{830, -96.8055, -24.445}, -0.444143}, {{830, \
-70.4581, -66.6819}, 2.98027}, {{830, -24.9342, -90.7701}, 
  5.61019}, {{830, 27.376, -90.1535}, 6.72985}, {{830, 72.2352, -65.},
   6.03451}, {{840, 73.8415, 65.}, -2.80912}, {{840, 28.5157, 
   90.9587}, -5.49089}, {{840, -24.6401, 
   91.9416}, -6.65017}, {{840, -71.0301, 
   67.6788}, -5.96864}, {{840, -97.9163, 
   24.8325}, -3.63343}, {{840, -97.9163, -24.8325}, -0.285765}, \
{{840, -71.0301, -67.6788}, 3.15515}, {{840, -24.6401, -91.9416}, 
  5.74449}, {{840, 28.5157, -90.9587}, 
  6.77127}, {{840, 73.8415, -65.}, 
  5.95354}, {{850, 75.4529, 65.}, -2.90552}, {{850, 29.6618, 
   91.7722}, -5.58791}, {{850, -24.3446, 
   93.1265}, -6.70959}, {{850, -71.6084, 
   68.6877}, -5.95989}, {{850, -99.039, 
   25.2247}, -3.54644}, {{850, -99.039, -25.2247}, -0.137702}, {{850, \
-71.6084, -68.6877}, 3.32222}, {{850, -24.3446, -93.1265}, 
  5.87505}, {{850, 29.6618, -91.7722}, 
  6.81372}, {{850, 75.4529, -65.}, 
  5.87826}, {{860, 77.3407, 64.7177}, -2.99704}, {{860, 31.1154, 
   92.5048}, -5.69395}, {{860, -23.8286, 
   94.3717}, -6.7843}, {{860, -72.0957, 
   69.7953}, -5.96259}, {{860, -100.161, 
   25.662}, -3.45904}, {{860, -100.161, -25.662}, 
  0.0248265}, {{860, -72.0957, -69.7953}, 
  3.51282}, {{860, -23.8286, -94.3717}, 
  6.0276}, {{860, 31.1154, -92.5048}, 
  6.8645}, {{860, 77.3407, -64.7177}, 
  5.78903}, {{870, 78.7876, 64.8939}, -3.07893}, {{870, 32.0813, 
   93.3861}, -5.78126}, {{870, -23.6704, 
   95.5476}, -6.84371}, {{870, -72.7481, 
   70.769}, -5.96672}, {{870, -101.314, 
   26.0367}, -3.39756}, {{870, -101.314, -26.0367}, 
  0.139378}, {{870, -72.7481, -70.769}, 
  3.64684}, {{870, -23.6704, -95.5476}, 
  6.13589}, {{870, 32.0813, -93.3861}, 
  6.90471}, {{870, 78.7876, -64.8939}, 
  5.73653}, {{880, 80.6211, 64.6615}, -3.15671}, {{880, 33.4818, 
   94.1425}, -5.88291}, {{880, -23.1974, 
   96.7996}, -6.92471}, {{880, -73.267, 
   71.876}, -5.98527}, {{880, -102.461, 
   26.473}, -3.33227}, {{880, -102.461, -26.473}, 
  0.27838}, {{880, -73.267, -71.876}, 
  3.81791}, {{880, -23.1974, -96.7996}, 
  6.27782}, {{880, 33.4818, -94.1425}, 
  6.9572}, {{880, 80.6211, -64.6615}, 
  5.66249}, {{890, 82.8576, 63.9689}, -3.2279}, {{890, 35.3509, 
   94.7482}, -6.00244}, {{890, -22.3795, 
   98.1257}, -7.03478}, {{890, -73.6376, 
   73.1246}, -6.02636}, {{890, -103.599, 
   26.9754}, -3.26881}, {{890, -103.599, -26.9754}, 
  0.440363}, {{890, -73.6376, -73.1246}, 
  4.02844}, {{890, -22.3795, -98.1257}, 
  6.45772}, {{890, 35.3509, -94.7482}, 
  7.02564}, {{890, 82.8576, -63.9689}, 
  5.56797}, {{900, 85.5153, 62.742}, -3.28935}, {{900, 37.7348, 
   95.1657}, -6.14521}, {{900, -21.1749, 
   99.5221}, -7.18461}, {{900, -73.8394, 
   74.5265}, -6.10099}, {{900, -104.726, 
   27.5507}, -3.21396}, {{900, -104.726, -27.5507}, 
  0.62502}, {{900, -73.8394, -74.5265}, 
  4.28371}, {{900, -21.1749, -99.5221}, 
  6.68306}, {{900, 37.7348, -95.1657}, 
  7.11542}, {{900, 85.5153, -62.742}, 
  5.45328}, {{910, 88.6145, 60.8757}, -3.33687}, {{910, 40.6962, 
   95.34}, -6.31928}, {{910, -19.5247, 
   100.983}, -7.38973}, {{910, -73.8433, 
   76.0979}, -6.22462}, {{910, -105.839, 
   28.2085}, -3.17617}, {{910, -105.839, -28.2085}, 
  0.834057}, {{910, -73.8433, -76.0979}, 
  4.59376}, {{910, -19.5247, -100.983}, 
  6.96637}, {{910, 40.6962, -95.34}, 
  7.23464}, {{910, 88.6145, -60.8757}, 
  5.31746}, {{920, 92.1776, 58.2182}, -3.36434}, {{920, 44.3228, 
   95.1902}, -6.53729}, {{920, -17.3447, 
   102.497}, -7.67401}, {{920, -73.6069, 
   77.8626}, -6.42023}, {{920, -106.93, 
   28.9628}, -3.16669}, {{920, -106.93, -28.9628}, 
  1.07268}, {{920, -73.6069, -77.8626}, 
  4.97675}, {{920, -17.3447, -102.497}, 
  7.32885}, {{920, 44.3228, -95.1902}, 
  7.39599}, {{920, 92.1776, -58.2182}, 
  5.15723}, {{930, 96.2294, 54.54}, -3.36165}, {{930, 48.7434, 
   94.5914}, -6.82032}, {{930, -14.5072, 
   104.05}, -8.07699}, {{930, -73.0659, 
   79.8561}, -6.72522}, {{930, -107.993, 
   29.8352}, -3.20221}, {{930, -107.993, -29.8352}, 
  1.35262}, {{930, -73.0659, -79.8561}, 
  5.46614}, {{930, -14.5072, -104.05}, 
  7.80794}, {{930, 48.7434, -94.5914}, 
  7.62062}, {{930, 96.2294, -54.54}, 
  4.96478}, {{940, 100.797, 49.4669}, -3.30952}, {{940, 54.1638, 
   93.3353}, -7.207}, {{940, -10.8032, 
   105.61}, -8.67185}, {{940, -72.1134, 
   82.1372}, -7.20822}, {{940, -109.014, 
   30.8612}, -3.31155}, {{940, -109.014, -30.8612}, 
  1.69917}, {{940, -72.1134, -82.1372}, 
  6.12786}, {{940, -10.8032, -105.61}, 
  8.47543}, {{940, 54.1638, -93.3353}, 
  7.94724}, {{940, 100.797, -49.4669}, 
  4.7221}, {{950, 105.91, 42.2999}, -3.16263}, {{950, 60.9619, 
   91.0248}, -7.77972}, {{950, -5.83869, 
   107.12}, -9.61826}, {{950, -70.5463, 
   84.8165}, -8.01919}, {{950, -109.965, 
   32.1088}, -3.55572}, {{950, -109.965, -32.1088}, 
  2.17212}, {{950, -70.5463, -84.8165}, 
  7.11111}, {{950, -5.83869, -107.12}, 
  9.49076}, {{950, 60.9619, -91.0248}, 
  8.45805}, {{950, 105.91, -42.2999}, 
  4.38318}, {{960, 111.6, 31.328}, -2.77116}, {{960, 70.0549, 
   86.668}, -8.77145}, {{960, 1.36414, 
   108.425}, -11.3871}, {{960, -67.8552, 
   88.1692}, -9.60467}, {{960, -110.782, 
   33.7488}, -4.11473}, {{960, -110.782, -33.7488}, 
  2.9554}, {{960, -67.8552, -88.1692}, 
  8.86615}, {{960, 1.36414, -108.425}, 
  11.3272}, {{960, 70.0549, -86.668}, 
  9.38486}, {{960, 111.6, -31.328}, 3.79183}};

How would you do it? It's probable something simple but i haven't found how to make it. Thanks in advance.

$\endgroup$
2
$\begingroup$

Update 2: And ... don't forget BubbleChart3D:

Modify {x,y,z} triples to {x, y, z, 1} and Style each each based on the second column values in data:

data2 = Style[Join[#, {1}], ColorData[{"Rainbow", {min, max}}][#2]] & @@@ data;

and use with BubbleChart3D:

BubbleChart3D[data2, BubbleSizes -> {.01, .01}, ViewPoint -> {1.5, -1.5, 2.5}, 
 ImageSize -> 500]

enter image description here


Original post:

{min, max} = Through@{Min, Max}@data[[All, 2]];

Simplest way is to use Graphics3D

Graphics3D[{ColorData[{"Rainbow", {min, max}}][#2], PointSize[Large], 
    Point@#} & @@@ data, ViewPoint -> {1.5, -1.5, 2.5}]

enter image description here

You get the same picture using ListPointPlot3D with a custom color function:

ClearAll[intf, cf]
intf = Interpolation[data, InterpolationOrder -> 1];
cf = Function[{x, y, z}, ColorData[{"Rainbow", {min, max}}][intf[x, y, z]]];

ListPointPlot3D[data[[All, 1]], BaseStyle -> PointSize[Large],
 ColorFunction -> cf,
 ColorFunctionScaling -> False, BoxRatios -> 1, 
 ViewPoint -> {1.5, -1.5, 2.5}]

Update: A simpler way to define the color function without using interpolation:

cf = Function[{x, y, z}, 
   ColorData[{"Rainbow", {min, max}}][{x, y, z} /. Rule @@@ data]];
$\endgroup$
  • $\begingroup$ @mnunos, my pleasure. Welcome to mma.se. $\endgroup$ – kglr Mar 21 '15 at 16:11
  • $\begingroup$ I think mnunos should vote up once the asnwer is accepted!!!! $\endgroup$ – ramesh Mar 21 '15 at 17:02
  • $\begingroup$ @ramesh, thank you for the vote. Sometimes new users are not aware that they can both accept and upvote. $\endgroup$ – kglr Mar 21 '15 at 17:12
1
$\begingroup$

As I understood, you mean something like this:

list = Flatten[Table[{i - 15, j - 15, 
     5 Exp[-(((i - 15)^2 + (j - 15)^2)/16)]}, {i, 0, 30}, {j, 0, 30}], 1];

ListPlot3D[list,
 PlotRange -> All, InterpolationOrder -> 3, MaxPlotPoints -> 25,
 ColorFunction -> Function[{x, y, z}, ColorData["Rainbow"][z]]]

enter image description here

I choose the "Rainbow" colorset but you of course can change it..

$\endgroup$
  • $\begingroup$ Not exactly, calculating the value is not so easy and i couldn't express it as a simple function like in your example (I have already seen almost the same in another question). kgulers answer is what i was searching. Thanks anyway. $\endgroup$ – Gypaets Mar 21 '15 at 16:11

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.