MATLAB——顏色梯度顯示


一、colormap函數

figure surf(peaks) k=1000; mycolor=spring(k); colormap(mycolor);

spring是顏色的分類。spring(k)生成k個梯度的漸變顏色值。

 

figure
surf(peaks)
colormap summer

 

二、colorbar函數

(1)

figure
surf(peaks)
colormap summer
colorbar

(2)調整colorbar顏色

figure
surf(peaks)
colormap
colorbar

在編輯中找到顏色編輯器

雙擊增加顏色塊,delete減少顏色塊,調整顏色即可

 

(3)位置調整和字體大小

clear all
figure
contourf(peaks)
colorbar('southoutside')

clear all
figure
contourf(peaks)
colorbar('southoutside','Ticks',[-5,-2,1,4,7],...
         'TickLabels',{'Cold','Cool','Neutral','Warm','Hot'})

clear all
figure
contourf(peaks)
c=colorbar('southoutside','Ticks',[-5,-2,1,4,7],...
         'TickLabels',{'Cold','Cool','Neutral','Warm','Hot'},'fontsize',12)
c.Label.String = 'Elevation (ft in 1000s)';
c.Label.FontSize = 15;

(4)調整高度

clear all
[X,Y,Z] = peaks(30);
surf(X,Y,Z)
colorbar
[cmin,cmax] = caxis

上面可以看到整個的數據組織形式,,x,y形成一個二維網格,z是對應點的高度,三維化就得到了如上的圖,caxis找到極值點。

 

clear all
[X,Y,Z] = peaks(30);
surf(X,Y,Z)
colorbar
[cmin,cmax] = caxis
caxis([0,cmax])%改變顏色塊的值

 

clear all
[X,Y,Z] = peaks(30);
surf(X,Y,Z)
colorbar
[cmin,cmax] = caxis
caxis([0,cmax])

%將0以下的由深藍變成黑色
map = colormap;
map(1,:) = [0 0 0];
colormap(map)

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM