Why is my 3-D plot not showing all of the data from my table row?

15 visualizaciones (últimos 30 días)
LoroEE
LoroEE el 30 de Mayo de 2022
Comentada: Walter Roberson el 8 de Nov. de 2024 a las 4:37
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 comentarios
KSSV
KSSV el 31 de Mayo de 2022
Check your data, (ax,ay,az) forms different layers.
So, when you have used griddata, you got the avrage of the data you have provided.
That is why you have missed the minimum value.
LoroEE
LoroEE el 31 de Mayo de 2022
So, according to your link, my data is in the surface, not the points? How do I show it on the graph then? I just want to show that the data in my table is on the graph somewhere. I don't understand what to do.
This code was adapted from another question and documentation, I don't understand it very well and don't know how layers work and how this is an issue.

Iniciar sesión para comentar.

Respuestas (1)

Vidhi Agarwal
Vidhi Agarwal el 8 de Nov. de 2024 a las 3:44
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 comentario
Walter Roberson
Walter Roberson el 8 de Nov. de 2024 a las 4:37
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.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by