一、圖形修飾處理
視覺處理
可以在圖形界面中手動旋轉
方位角(旋轉角)
- 視點在x軸的投影與y軸負半軸 形成角
- +:表示逆時針
- -:表示順時針
仰角(視角)
- +:在xy平面上方
- -:在xy平面的下方
view函數
view(az,el)
- az爲方位角,el爲仰角(單位:°)
- 默認: az=-37.5;el=30
view(x,y,z)
- 笛卡爾座標系
view(2)
- 在二維平面中觀察
view(3)
- 在三位平面內觀察
色彩處理
顏色的向量表示
[R G B] ( 紅 綠 藍)
[0 0 1]:藍色
[1 0 0]:紅色
[0 1 0]:綠色
[1 1 1]:白色
[0 0 0]:黑色
色圖
色圖矩陣
內建色圖
指定當前圖形使用的色圖
colormap 內建色圖名
默認情況圖一
surf(peaks)
title('默認parula')
引用了其他色圖圖二
surf(peaks)
colormap hot;
title('用hot色圖')
colormap(色圖矩陣)
色圖矩陣每一行是RGB三元組
c=[0 0.2 0.4 0.6 0.8 1]';
cmap=[c,c,c];
surf(peaks);
colormap(cmap);
title('創建色圖矩陣')
三維圖形表面上色
- shading faceted: 將每個網格排尿用其高度對應的顏色進行着色,網格線是黑色的。
- shading flat: 將每個網絡片用同一個顏色進行作色,且網絡格線也着色。
- shading interp: 在網絡片內採用顏色插值處理,表面塗最光滑
[x,y,z]=cylinder(pi:-pi/5:0,10);
colormap(lines);
subplot(1,3,1);
surf(x,y,z);
shading flat
title('flat');
subplot(1,3,2);
surf(x,y,z);
shading interp
title('interp');
subplot(1,3,3);
surf(x,y,z);
shading faceted
title('faceted');
裁剪處理
將圖形中將要裁剪的部分對應的函數值設置成NaN,該部分在圖形繪製出來將不顯示。
二維剪裁
t=linspace(0,2*pi,100);
x=sin(t);
y=cos(t);
p=y>0.5;
y(p)=NaN;
plot(x,y);
axis([-1.1,1.1,-1.1,1.1]);
axis square
grid on
三維剪裁
[X,Y,Z]=sphere(60);
p=Z>0.5;
Z(p)=NaN;
surf(X,Y,Z)
axis equal