Matlab Surface: Assign different color for specific portions of the graph.
2 ビュー (過去 30 日間)
古いコメントを表示
Hi guys,
Is it possible to color different areas of ONE surface? and also have a legend?
Can I ask that anything > (25,25) be blue and less be red in the following example? Thanks!
x = [0:50];
y = [0:50];
Test1 = @(x,y) x.^2+y.^2;
[X1,Y1] = meshgrid(x,y);
Z1 = Test1(X1,Y1);
s1 = surf(X1,Y1,Z1,'LineStyle','none');
0 件のコメント
回答 (1 件)
Ahmet Cecen
2015 年 5 月 4 日
How about:
x = [0:50];
y = [0:50];
Test1 = @(x,y) x.^2+y.^2;
[X1,Y1] = meshgrid(x,y);
Z1 = Test1(X1,Y1);
s1 = surf(X1,Y1,Z1,'LineStyle','none');
s1.FaceColor='blue';
hold on;
x = [0:25];
y = [0:25];
Test1 = @(x,y) x.^2+y.^2;
[X1,Y1] = meshgrid(x,y);
Z1 = Test1(X1,Y1);
s1 = surf(X1,Y1,Z1,'LineStyle','none');
s1.FaceColor='red';
4 件のコメント
Ahmet Cecen
2015 年 5 月 5 日
x = [0:10];
y = [0:10];
Eq1 = @(x,y)(x+y);
Eq2 = @(x,y)(2.*x+y);
BigEq = @(x,y) [Eq1(x,y).*(Eq2(x,y)>5)];
[X1,Y1] = meshgrid(x,y);
Z1 = BigEq(X1,Y1);
Z1(Z1==0)=NaN; % Get rid of zeros.
Z1(7:10,7:10)=NaN; % Get rid of the green surface where red will come, to resolve clipping.
s1 = surf(X1,Y1,Z1);
set(s1,'FaceColor','green');
hold on;
x = [5:10];
y = [5:10];
BigEq = @(x,y) [Eq1(x,y).*(Eq2(x,y)>5)];
[X1,Y1] = meshgrid(x,y);
Z1 = BigEq(X1,Y1);
s1 = surf(X1,Y1,Z1);
set(s1,'FaceColor','red');
hold off;
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!