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

3 Ansichten (letzte 30 Tage)
Muazma Ali
Muazma Ali am 2 Aug. 2022
Beantwortet: Narvik am 5 Sep. 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)

Antworten (1)

Narvik
Narvik am 5 Sep. 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!

Kategorien

Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by