Is it possible to make surface plot with two grouping variables?

3 visualizaciones (últimos 30 días)
Muazma Ali
Muazma Ali el 2 de Ag. de 2022
Respondida: Narvik el 5 de Sept. de 2024
Hi!:)
I want to use surf function with two grouping variables meaning in addition to the z value I want to add another value, is it posssible with surf function?
( I cant use gscatter as I dont have the add on tool box)

Respuestas (1)

Narvik
Narvik el 5 de Sept. de 2024
Hi Muazma Ali,
As per my understanding, you want to visualize additional information (like a grouping variable) on a surface plot.
To visualize an additional grouping variable on a surface plot using "surf" function, map the grouping variable to color.
Refer to the following documentation link for more information on "surf" function:
Refer to the following sample code to visualize additional grouping variable on surface plot:
% sample data
[x, y] = meshgrid(-5:0.5:5, -5:0.5:5);
z = sin(sqrt(x.^2 + y.^2));
g = x + y; % grouping variable
% create surface plot
figure;
surf(x, y, z, g, 'EdgeColor', 'none'); % using g for color data
colormap(jet);
colorbar;
% labels
xlabel('X-axis');
ylabel('Y-axis');
zlabel('Z-axis');
title('Surface Plot with Grouping Variable');
Hope this helps!

Categorías

Más información sobre Lighting, Transparency, and Shading en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by