Why is my 3-D plot not showing all of the data from my table row?
3 views (last 30 days)
Show older comments
The table is in the file attached. This is the code I used:
Q1 = tabela_viaveis_ordenada(1:height(tabela_viaveis_ordenada),:);
VarNames = tabela_viaveis_ordenada.Properties.VariableNames;
ax = Q1{:,7};
ay = Q1{:,6};
az = Q1{:,2};
% create a grid basis and then interpolate on the grid
n = 50;
x11 = linspace(min(ax),max(ax),n);
y11 = linspace(min(ay),max(ay),n);
z11 = griddata(ax,ay,az,x11',y11);
% plot it
surf(x11,y11,z11)
xlabel(VarNames{7})
ylabel(VarNames{6})
zlabel(VarNames{2})
The 3-D plot looks like this, Z axis is "custo_total" variable from second row:
The smallest value of Z is 63348.2 in the graph but 55688.7 on the table.
In other words, my 3-D plot seems to skip over some data so I can't actually find the points I want using the "Data Tips" thing.
Why?
2 Comments
KSSV
on 31 May 2022
Check your data, (ax,ay,az) forms different layers.
That is why you have missed the minimum value.
Answers (1)
Vidhi Agarwal
on 8 Nov 2024
While using “griddata” function, the minimum value plotted in the graph is the interpolated value. Depending on the interpolation method used, it can smooth out the data, potentially missing some of the original data points, especially if they are outliers or isolated.
By Directly plotting the original data points on top of the interpolated surface you can visually ensure that original data points, including the minimum are represented in the graph. By this it is ensured that you have a smooth representation of data, and an accurate display of minimum.
By adding the following lines of code to the existing one, the issue must get resolved:
% Overlay original data points for reference
hold on;
plot3(ax, ay, az, 'o', 'MarkerFaceColor', 'r', 'MarkerEdgeColor', 'k');
hold off;
Hope that helps!
1 Comment
Walter Roberson
on 8 Nov 2024
With most of the interpolation methods, including the default interpolation method for griddata , if (x,y) pairs on input are unique, then querying at exactly (x,y) will give back exactly the z that was present immediately. That is, given unique input points, most of the interpolation methods do not smooth data when queried at the original input points.
However, for all of the interpolation methods, something has to happen if there are duplicate (x,y) pairs in the input. In such cases, griddata() takes the mean() of each of the input z for each unique (x,y) pairs.
It happened that @LoroEE input data included a number of cases of the same (x,y) with different z. Those locations were each averaged out, and that is the reason that the output did not include the minimum of the data.
See Also
Categories
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!