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

3 次查看(过去 30 天)
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)

回答(1 个)

Narvik
Narvik 2024-9-5
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!

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by