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)
0 个评论
回答(1 个)
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!
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!