1
$\begingroup$

This question builds on ColorFunction for ListPointPlot3D (but is different), and has something in common with Some Issues with ListPlot3D. I have a large data set, about 6000 points, which is anything but smooth. Therefore, when attempting to use ListPlot3D I get a mess. ListPointPlot3D looks much nicer. However, what I am really trying to do is to animate the surface as the z-values change over time, something not unlike a time-dependent wave function but much messier than the nice geometries that are usually shown in physics textbooks. The point is that the individual points moving up and down are not suggestive at all of what the system is doing. I think a surface would look much nicer.

Since Animate was choking I filtered my data set from 6000 down to 150, to see if it would help. Animate seemed happier, but the surface still looks horrible. Is there another way to do this? In principle I could do some smoothing using local averages, and could even code my own splines, but I'd rather avoid all that work if there is an easier solution in MMA.

This is the data:

data = {{41.9752, 51.0084, -0.14}, {46.3064, 55.7369, 0}, {41.4526, 57.7858, 
  0}, {37.0897, 9.06416, 0}, {44.0334, 55.3856, 1098.}, {44.5004, 
  50.5896, -3778.25}, {44.6699, 53.0785, 0}, {32.7899, 7.67608, 
  0}, {40.6237, 58.6538, 0}, {50.261, 63.6736, 0}, {46.7637, 51.6856, 
  0}, {42.2847, 50.6747, 0}, {44.9239, 56.1008, 2619.29}, {32., 
  8.8501, 0}, {46.951, 51.1587, -31.16}, {41.8275, 
  51.7466, -1318.44}, {41.3532, 50.1727, -105.16}, {36.9869, 12.2926, 
  0}, {46.7228, 50.8667, 0}, {37.7692, 12.9168, 0}, {41.7265, 
  56.5381, -4748.22}, {45.4683, 51.9324, 5866.5}, {46.9676, 55.7092, 
  3596.78}, {47.0195, 56.0355, -2888.82}, {44.9408, 52.8141, 
  3537.41}, {40.5041, 52.5762, -785.58}, {46.3697, 55.1177, 
  24437.9}, {46.5075, 52.7793, 6381.1}, {42.1066, 52.3115, 
  0}, {43.7638, 52.579, -1678.97}, {40.8018, 54.2717, 
  765.08}, {47.1229, 54.067, -3.14}, {43.53, 
  50.847, -308.73}, {45.7926, 53.2121, 1877.38}, {45.9816, 
  49.7133, -2206.46}, {41.8471, 56.9826, -3644.37}, {46.8182, 57.0748,
   0}, {46.4614, 57.0546, 3537.04}, {44.3906, 
  49.8397, -95.48}, {42.8532, 53.7472, 0}, {41.0753, 
  54.8614, -2645.17}, {46.527, 54.9125, 296.46}, {46.2186, 52.4254, 
  362.76}, {46.6058, 55.898, 0}, {41.1755, 51.0297, 3324.5}, {46.8637,
   51.3181, 1842.}, {47.2415, 52.9983, 0}, {41.4212, 
  55.1318, -1573.71}, {45.1927, 57.621, -18137.7}, {32.3229, 12.9559, 
  3518.32}, {41.6235, 51.1068, -9030.14}, {41.4681, 
  54.4837, -2248.1}, {46.6901, 51.5766, -37.}, {42.2132, 54.288, 
  5281.32}, {45.4498, 51.9611, 3824.89}, {46.2361, 50.0177, 
  0}, {44.2535, 54.8271, -2895.34}, {41.1416, 50.1497, 300.}, {41.358,
   51.126, -9.}, {46.7152, 53.7666, 0}, {44.3487, 
  51.8547, -16165.}, {45.9185, 53.572, 2486.16}, {43.9951, 59.6359, 
  0}, {40.6944, 53.5781, -392.25}, {46.6571, 54.7528, 
  2824.78}, {40.6697, 57.3428, 0}, {32.1574, 8.29045, 0}, {36.3133, 
  11.7769, 0}, {41.7442, 57.3415, 0}, {46.1835, 51.8171, 0}, {33.962, 
  7.46025, 0}, {41.3828, 49.5177, 0}, {42.2609, 54.4367, 0}, {44.3983,
   51.9676, 0}, {45.1485, 53.0748, 0}, {41.3917, 51.5585, 
  1297.88}, {46.0339, 56.7402, 0}, {41.5515, 51.2253, 0}, {43.6329, 
  52.3359, -2944.2}, {41.6153, 49.6948, 0}, {47.5086, 54.6066, 
  390.17}, {42.7066, 49.9891, 3922.52}, {45.6843, 
  55.6495, -3.79}, {41.635, 51.9439, 191.}, {32.0001, 10.6268, 
  0}, {46.6047, 52.9617, 0}, {42.1589, 50.2209, -1.65}, {45.9651, 
  53.4673, 0}, {45.9121, 51.9338, -2.17}, {46.7053, 
  56.812, -7.95}, {46.8959, 50.0061, -2939.02}, {46.261, 55.0001, 
  0}, {40.8267, 51.5277, -65.94}, {42.5194, 53.8732, 0}, {46.3536, 
  52.0995, 20784.1}, {42.5783, 55.5909, -258.99}, {46.3857, 52.5256, 
  0}, {37.684, 11.2986, 0}, {46.5173, 51.265, -190.}, {46.7752, 
  54.2789, -2090.14}, {46.3235, 50.7689, -160.}, {46.645, 50.9865, 
  307.28}, {41.0521, 54.7299, -30.}, {41.1671, 
  50.1607, -21.39}, {40.6418, 51.4803, -339.59}, {46.9327, 50.9302, 
  0}, {44.4319, 51.6602, -113.47}, {41.1641, 49.8618, 0}, {44.9775, 
  55.8933, -679.04}, {46.4108, 54.1753, -5.39}, {47.0044, 
  57.4148, -51.07}, {41.2795, 55.2478, -137.7}, {41.4669, 
  49.9743, -12.06}, {45.219, 50.3463, -105.95}, {41.415, 
  55.6961, -1145.97}, {37.0407, 12.4914, 0}, {43.6257, 
  51.8323, -1138.09}, {45.5592, 55.8865, -1622.88}, {44.0226, 
  50.5775, -7922.37}, {43.5978, 52.6999, -9.19}, {46.9201, 
  53.3202, -85.}, {42.9565, 50.1511, -7860.58}, {36.2029, 11.5759, 
  0}, {41.9505, 56.8232, -10.}, {40.5219, 61.1463, 0}, {41.9827, 
  55.6912, -3973.97}, {45.9311, 51.6254, 24839.2}, {43.0259, 
  54.0691, -15.62}, {46.7425, 52.0979, 0}, {43.3607, 
  51.91, -25.95}, {42.6043, 52.6308, 4035.6}, {41.5247, 
  50.002, -13.2}, {41.9012, 52.0415, -239.21}, {40.8, 
  52.6618, -175.}, {43.9595, 58.3097, 0}, {46.1142, 64.4864, 
  0}, {41.8076, 59.8467, 0}, {40.8276, 60.555, 0}, {41.2004, 55.1121, 
  0}, {43.5315, 53.8038, -743.34}, {46.9943, 49.7573, 610.}, {42.2476,
   50.4976, -30.81}, {45.3413, 49.8177, -5322.74}, {40.6275, 
  50.8964, -2164.34}, {43.695, 50.6122, 2471.29}, {46.4401, 
  50.2781, -129.44}, {47.4432, 59.0342, 0}, {43.6994, 50.9732, 
  0}, {41.7523, 50.3442, -1813.93}, {41.4528, 54.8583, 2321.46}}

This is the ListPlot3D command:

ListPlot3D[data,
    PlotStyle -> PointSize[0.01],
    ColorFunction ->
        (Piecewise[{{RGBColor[0, 1, 0], #3 >= 0},
         {RGBColor[0, 0, 1], #3 < 0}}] &),
    ColorFunctionScaling -> False,
    PlotRange -> {{38, 50}, {48, 60}, {-20000, 30000}},
    InterpolationOrder -> 3]

And the ListPointPlot3D command:

ListPointPlot3D[data,
    PlotStyle -> PointSize[0.01],
    ColorFunction -> 
        (Piecewise[{{RGBColor[0, 1, 0], #3 >= 0},
         {RGBColor[0, 0, 1], #3 < 0}}] &),
    ColorFunctionScaling -> False,
    PlotRange -> {{38, 50}, {48, 60}, {-20000, 30000}}]

=============

(Edit)

Because of the comments I thought I would add some pictures. First I should explain that due to privacy considerations I have scrambled the data, so what I plot here are different sets of points, although for the low-res case the number of points is the same as the data above. Qualitatively it's the same kind of data.

Low-res, surface (150 points): enter image description here

Low-res, points (same set of points as surface pic, but different from above): enter image description here

Hi-res, surface (5444 points, not quite 6000. This is not a hi-res version of the low-res pictures, it's a different set of points. However, qualitatively they are analogous): enter image description here

Hi-res, points (same 5444 points as for surface): enter image description here

(/Edit)

=============

There is a corollary to this question. The points above are confined to a finite singly-connected region. If I defined an arbitrary boundary (like the border of a geographical region), would it be possible to clip the surface so it stops at the boundary and is only drawn inside it? Plotting such a boundary with a thick red line, for example, could make the surface look even better.

Many thanks.

$\endgroup$
  • $\begingroup$ It's possible that the surface quality is poor because of different reasons. Where in the first instance your pc couldn't keep up with the amount of points, and in the second instance you simply have too few points. How does it look when you use all 6000 points to make one snapshot in time with this code without Animate[]? 150 points is really quite few, just check , InterpolationOrder -> 0, Filling -> Bottom, Mesh -> None. $\endgroup$ – Feyre Oct 16 '16 at 17:50
  • $\begingroup$ In my opinion, for such a bumpy non-smooth surface you should really give your eyes as much guide as possible. I would Blend in the ColorFunction to make the transition smoother. Additionally, I would use a narrow grid that is clearly visible. Something along this i.stack.imgur.com/sTarQ.png $\endgroup$ – halirutan Oct 16 '16 at 18:29
  • $\begingroup$ @Feyre please see pictures in the edit above. I tried your commands and the result looks really cool. It reminds me of the Giant Causeway en.wikipedia.org/wiki/Giant%27s_Causeway. However, that's not quite what I was looking for. Using my original code as for the pics above you can see that the quality is pretty poor for both hi-res and low-res versions. $\endgroup$ – pdini Oct 17 '16 at 8:22
  • $\begingroup$ @halirutan, thanks, this is what I am looking for! When I added Mesh -> Full or some value like 200 to my code, however, I got a mesh with a rectangular aspect ratio. How did you get square cells? $\endgroup$ – pdini Oct 17 '16 at 8:23
  • $\begingroup$ @halirutan, could you please also add your code? Thanks. $\endgroup$ – pdini Oct 17 '16 at 8:47
0
$\begingroup$

As per request

@halirutan, could you please also add your code? Thanks. – pdini

here the code that plots the surface with a Blend color function and a fine grained, squared mesh:

ListPlot3D[data, PlotStyle -> PointSize[0.01], 
 ColorFunction -> Function[{x, y, z}, Blend[{Blue, Gray, Green}, z]], 
 PlotRange -> {{38, 50}, {48, 60}, {-20000, 30000}}, 
 Mesh -> {Range[38, 50, .5], Range[48, 60, .5]}, MeshStyle -> White]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thank you very much, I get the Mesh spec now. How did you get the surface to stop before the width of the box? Perhaps it's just an artifact of the jpeg mapping? $\endgroup$ – pdini Oct 18 '16 at 10:37
  • $\begingroup$ I did nothing. In fact, I'm sure the plot in your question shows this as well. $\endgroup$ – halirutan Oct 18 '16 at 11:27

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.