Plotting two regions such that they can be identified nicely
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi I have two regions in 2D which looks almost the same (one is a little bigger than the other) and I want to plot them so that they can be identified separately. The mat file and the code is attached:
x1 = -1.5:0.02:1.5;
x2 = -1.5:0.02:1.5;
[X1,X2] = meshgrid(x1,x2);
load('U_FF_h_p_02.mat')
load('U_FF_YMP_h_p_02 (1).mat')
figure(1)
%%
surf(X1,X2,U, 'FaceAlpha', 0.1)
view(2)
figure(2)
surf(X1,X2,U_Y, 'FaceAlpha', 1)
view(2)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
I want to plot them on the same figure and when I do this they look the same and can't really be distinguished. Any ideas?
1 Kommentar
Mathieu NOE
am 9 Jun. 2023
I don't understand what you want
if you plot each one on a separate plot , they can be distinguished - or subplots / stacked plots same story
or have separate colormap ?
in which way do you want to make them distinguishable ?
Antworten (1)
Rahul
am 15 Jun. 2023
One method to make the 2 regions more easily distinguishable can be to use different colors or shading for each region. This can be adjusted using the FaceColor property of the surface objects. The below given code is a good representation for this.
x1 = -1.5:0.02:1.5;
x2 = -1.5:0.02:1.5;
[X1, X2] = meshgrid(x1, x2);
load('U_FF_h_p_02.mat')
load('U_FF_YMP_h_p_02 (1).mat')
color1 = [0, 0.5, 1];
color2 = [1, 0.5, 0];
figure;
surf(X1, X2, U, 'FaceColor', color1, 'FaceAlpha', 0.5);
hold on;
surf(X1, X2, U_Y, 'FaceColor', color2, 'FaceAlpha', 0.5);
view(2);
grid on;
c = colorbar;
c.Label.String = 'Value';
title('Comparison of U and U_Y');
xlabel('X1');
ylabel('X2');
zlabel('U');
Here I have tweaked the code given by adding FaceColor values to the surf function and adjusting the transparency for better visualization. color1 and color2 are the color values (blue and orange) used to highlight the region depicting U and U_Y respectively.
The hold on command keeps all plotted surfaces in the same figure and grid on command will add a grid in the plot. A colorbar is also included to show corresponding levels of the surfaces.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots 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!