| 1 | 1/1 | 返回列表 |
| 查看: 3781 | 回復(fù): 0 | |||
[交流]
怎樣在同一個圖中畫兩個等高線圖?
|
|
目的: 存在兩組等高線,兩組等高線有交集。將兩個等高線畫在同一個圖中,每組等高線使用不同的colormap, 兩組等高線的交集應(yīng)該是兩組顏色的重疊。 實現(xiàn)方法一 使用contour,不用填充顏色的contourf,以便第二組等高線不會覆蓋住第一組的交集部分。使用例如colormap([cool(64);gray(64)])命令,將colormap變成兩種色彩集的合并。 例子1 clear all % clear all the data in the workspace close all % close all the current figures clc % clear the command window %----------------------------- % generate the data [X,Y,Z1] = peaks(64); % X,Y,Z data of the first group Z2=X.^2+Y.^2; % Z data of the second group %% % first method % use two axes in the same figure % set the figure's properties h=figure scrsz = get(0,'ScreenSize'); set(h,'Position',[scrsz(4).*(1/8) scrsz(4).*(1/20) scrsz(3)*3/5 scrsz(4).*(4/5)]) %-------------------------------------------------------------------------- % the first axes hAxes(1)=axes('Unit','pixels','position',[100 100 400 400]); %-------- % combine two colormap in the same one, here we use 'jet' and 'gray' colormap([jet(64);gray(64)]) % the jet color will be used two index the first contour and the gray will % be used for the second one. %-------- [c1,h1] = contour(X(1, ,Y(:,1),Z1); % plot the first contourset(h1,'ShowText','on') cmin1=min(Z1( );cmax1=max(Z1( );% use caxis to set the limit of the colorbar, the first one will occupy the % low half one caxis(hAxes(1),[cmin1,2*cmax1-cmin1]) % then define the axis set(hAxes(1),'YColor','k','Box','on'); set(hAxes(1),'FontName','Helvetica','FontSize',20,'LineWidth',1) xlabel(hAxes(1),'$ X $ [-]','Color','k','Interpreter','LaTex','FontSize',20); ylabel(hAxes(1),'$ Y $ [-]','Color','k','Interpreter','LaTex','FontSize',20); set(hAxes(1),'xlim',[min(X(1, ), max(X(1, )],'YAxisLocation','left','Color','w');set(hAxes(1),'ylim',[min(Y(:,1)), max(Y(:,1))]); %-------------------------------------------------------------------------- % the second axes hAxes(2)=axes('Unit','pixels','position',get(hAxes(1),'position')); [c2,h2] = contour(X(1, ,Y(:,1),Z2); % plot the second contourcmin2=min(Z2( );cmax2=max(Z2( );% use caxis to set the limit of the colorbar, the second one will occupy the % higher half one caxis(hAxes(2),[2*cmin2-cmax2,cmax2]) set(hAxes(2),'visible', 'off') % the the visable of axes 2 off 實現(xiàn)方法二 原則上來說,在一個figure中只能使用一種colormap,所以如果不像第一種方法定義colorbar,兩組等高線的色調(diào)是一樣的。解決這個問題可以采用freezecolor方法,即第一個contour采用一中colormap,然后freeze, 對第二個contour采用另外一個colormap,也freeze。 具體可以參考 http://ycc.math.fju.edu.tw/research/biology/b2012fMRI/fMRICODE/simtb_v18/simtb_v18/display/freezeColors/demo/html/freezeColors_pub.html |

找到一些相關(guān)的精華帖子,希望有用哦~
| 1 | 1/1 | 返回列表 |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 085600材料與化工調(diào)劑 324分 +8 | llllkkkhh 2026-03-18 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 材料專業(yè)求調(diào)劑 +5 | hanamiko 2026-03-18 | 5/250 |
|
|
[考研] 344求調(diào)劑 +6 | knight344 2026-03-16 | 7/350 |
|
|
[考研]
|
.6lL 2026-03-18 | 4/200 |
|
|
[考研] 【同濟軟件】軟件(085405)考研求調(diào)劑 +3 | 2026eternal 2026-03-18 | 3/150 |
|
|
[考研] 一志愿中國海洋大學(xué),生物學(xué),301分,求調(diào)劑 +4 | 1孫悟空 2026-03-17 | 4/200 |
|
|
[考研] 0854可跨調(diào)劑,一作一項核心論文五項專利,省、國級證書40+數(shù)一英一287 +8 | 小李0854 2026-03-16 | 8/400 |
|
|
[考研] 0703化學(xué)調(diào)劑 +4 | pupcoco 2026-03-17 | 7/350 |
|
|
[考研] 環(huán)境工程調(diào)劑 +8 | 大可digkids 2026-03-16 | 8/400 |
|
|
[考研] 334求調(diào)劑 +3 | 志存高遠(yuǎn)意在機?/a> 2026-03-16 | 3/150 |
|
|
[考研] 268求調(diào)劑 +8 | 一定有學(xué)上- 2026-03-14 | 9/450 |
|
|
[考研] 326求調(diào)劑 +5 | 上岸的小葡 2026-03-15 | 6/300 |
|
|
[考研] 本人考085602 化學(xué)工程 專碩 +16 | 不知道叫什么! 2026-03-15 | 18/900 |
|
|
[基金申請] 國自科面上基金字體 +6 | iwuli 2026-03-12 | 7/350 |
|
|
[考研] 0703 物理化學(xué)調(diào)劑 +3 | 我可以上岸的對?/a> 2026-03-13 | 5/250 |
|
|
[考研] 289求調(diào)劑 +4 | 這么名字咋樣 2026-03-14 | 6/300 |
|
|
[考研] 工科材料085601 279求調(diào)劑 +8 | 困于星晨 2026-03-12 | 10/500 |
|
|
[考研] 295求調(diào)劑 +3 | 小匕仔汁 2026-03-12 | 3/150 |
|
|
[考研] 085600材料與化工 309分請求調(diào)劑 +7 | dtdxzxx 2026-03-12 | 8/400 |
|
|
[考研] 070303一志愿西北大學(xué)學(xué)碩310找調(diào)劑 +3 | d如愿上岸 2026-03-13 | 3/150 |
|