# Plotting Noisy Experimental data

I want to plot experimental data (from the atomic absorption), but it is hard to make smooth the data. I tried to use Gaussian Filter, but it only works for the 1D data, and I am not sure how I can apply to 3D data.

Here is the sample model (because of the large file).

data6 = << "https://pastebin.com/raw/t2yf551A";

ListContourPlot[data6
, ColorFunction -> (ColorData["TemperatureMap"][
Rescale[#, {0.4, 1}]] &), ColorFunctionScaling -> False,
ClippingStyle -> Automatic, Contours -> 30, ImageSize -> 800,
AspectRatio -> 1, InterpolationOrder -> 3]


My theory predicts the plot such that,

I am seeing kind of matching behavior, but due to the noise, it is hard to make any point. Especially, the data near x=0, there is a sharp change, so my interpolation failed to capture the behavior.

Just in case, here is original data from google drive,

hhh1i = Interpolation[RandomSample[data4, 30000]]
data6 = Select[
Flatten[
Table[{x - y, y,
hhh1i[57.14285714285714 (0.775 + 1. x), y]}, {x, -0.8, 0.8,
0.01}, {y, -0.4, 0.8, 0.01}], 1]
, -0.2 < #[[1]] < 0.2 && -0.4 < #[[2]] < 0.6 &];

• Can you supply the explicit model that your theory predicts? If you have a model, that should be taken into consideration as opposed to smoothing that completely ignores the model.
– JimB
Oct 6 '20 at 0:30
• @JimB I can provide model which is really complicated, but I don't want to use model to smooth the data, I want to show that my experiment match with model. I tried to use Gaussian filter, but I am not sure how I can apply to 3D data. Oct 6 '20 at 2:57
• If you want to show that your model matches the data, why not just use some metric such as the mean square error? Or plot the residuals to see where the model fits and doesn't fit so well? The issue about smoothing is that where the model changes rapidly in an area you probably want less smoothing.
– JimB
Oct 6 '20 at 3:04
• Do not use any interpolation, any smoothing of the experimental data. Show as it is, for otherwise it means you invent the data. It is perfectly fine to show side by side noisy experimental data and the respective smooth theoretical prediction. Oct 6 '20 at 9:59

The first obstacle for smoothing is, that your data are not ordered. There is no neighbour relationship. Therefore, first you need to sort the data. Then you may use "ArrayFilter" with some filter function. For an example, I will use the simple Mean, but you may try more sophistic smoothing.

dat = Sort@data6;
dat[[All, 3]] = ArrayFilter[Mean[Flatten[#]] &, dat[[All, 3]], 10];

ListContourPlot[dat,
ColorFunction -> (ColorData["TemperatureMap"][
Rescale[#, {0.4, 1}]] &), ColorFunctionScaling -> False,
ClippingStyle -> Automatic, Contours -> 30, ImageSize -> 800,
AspectRatio -> 1, InterpolationOrder -> 3]


• Thank you, it is simple, but works really well. Oct 6 '20 at 15:21

There are several ways to do what OP requests. Below is one way using standard interpolation.

First we interpolate the data:

data = << "https://pastebin.com/raw/t2yf551A";
F = Interpolation[Map[{Most[#], Last[#]} &, data], InterpolationOrder -> 1];


Here we plot together as scatter plot of the original data and 3D plot with the interpolation function:

Show[
ListPointPlot3D[data, PlotStyle -> Blue,
PlotLegends ->
SwatchLegend[{Blue, Orange}, {"data", "interpolated"}]],
Plot3D[F[x, y], {x, Min[data[[All, 1]]], Max[data[[All, 1]]]}, {y,
Min[data[[All, 2]]], Max[data[[All, 2]]]},
PerformanceGoal -> "Speed", Mesh -> All],
PlotLegends -> {"data", "interpolated"},
ImageSize -> Large
]


Alternatively, we compute the interpolated points on a regular grid first and then (list-)plot them:

lsPoints =
Flatten[Table[{x, y, F[x, y]}, {x, Min[data[[All, 1]]],
Max[data[[All, 1]]], 0.02}, {y, Min[data[[All, 2]]],
Max[data[[All, 2]]], 0.02}], 1];

Show[
{ListPointPlot3D[data, PlotStyle -> Blue,
PlotLegends ->
SwatchLegend[{Blue, Orange}, {"data", "interpolated"}]],
ListPlot3D[lsPoints]},
ImageSize -> Large
]
`

• Thank you so much for help Oct 6 '20 at 15:22
• @SaesunKim Sure, good luck! Oct 6 '20 at 19:55