| 24小時(shí)熱門版塊排行榜 |
| 1 | 1/1 | 返回列表 |
| 查看: 3780 | 回復(fù): 0 | |||
[交流]
怎樣在同一個(gè)圖中畫(huà)兩個(gè)等高線圖?
|
|
目的: 存在兩組等高線,兩組等高線有交集。將兩個(gè)等高線畫(huà)在同一個(gè)圖中,每組等高線使用不同的colormap, 兩組等高線的交集應(yīng)該是兩組顏色的重疊。 實(shí)現(xiàn)方法一 使用contour,不用填充顏色的contourf,以便第二組等高線不會(huì)覆蓋住第一組的交集部分。使用例如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 實(shí)現(xiàn)方法二 原則上來(lái)說(shuō),在一個(gè)figure中只能使用一種colormap,所以如果不像第一種方法定義colorbar,兩組等高線的色調(diào)是一樣的。解決這個(gè)問(wèn)題可以采用freezecolor方法,即第一個(gè)contour采用一中colormap,然后freeze, 對(duì)第二個(gè)contour采用另外一個(gè)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ā)表 | |
|---|---|---|---|---|
|
[考研] 304求調(diào)劑 +6 | 司空. 2026-03-18 | 6/300 |
|
|---|---|---|---|---|
|
[考研] 085410人工智能專碩317求調(diào)劑(0854都可以) +3 | xbxudjdn 2026-03-18 | 3/150 |
|
|
[考研] 281求調(diào)劑(0805) +6 | 煙汐憶海 2026-03-16 | 15/750 |
|
|
[考研] 295求調(diào)劑 +3 | 一志愿京區(qū)211 2026-03-18 | 5/250 |
|
|
[考研] 286求調(diào)劑 +6 | lemonzzn 2026-03-16 | 9/450 |
|
|
[考研] 08工科 320總分 求調(diào)劑 +5 | 梨花珞晚風(fēng) 2026-03-17 | 5/250 |
|
|
[考研] 0854可跨調(diào)劑,一作一項(xiàng)核心論文五項(xiàng)專利,省、國(guó)級(jí)證書(shū)40+數(shù)一英一287 +8 | 小李0854 2026-03-16 | 8/400 |
|
|
[考研] 0703化學(xué)調(diào)劑 ,六級(jí)已過(guò),有科研經(jīng)歷 +10 | 曦熙兮 2026-03-15 | 10/500 |
|
|
[考研] 301求調(diào)劑 +9 | yy要上岸呀 2026-03-17 | 9/450 |
|
|
[碩博家園] 湖北工業(yè)大學(xué) 生命科學(xué)與健康學(xué)院-課題組招收2026級(jí)食品/生物方向碩士 +3 | 1喜春8 2026-03-17 | 5/250 |
|
|
[考研] 材料專碩326求調(diào)劑 +6 | 墨煜姒莘 2026-03-15 | 7/350 |
|
|
[考研] 26考研求調(diào)劑 +6 | 丶宏Sir 2026-03-13 | 6/300 |
|
|
[考研] 290求調(diào)劑 +6 | 孔志浩 2026-03-12 | 11/550 |
|
|
[考研] 080500,材料學(xué)碩302分求調(diào)劑學(xué)校 +4 | 初識(shí)可樂(lè) 2026-03-14 | 5/250 |
|
|
[考研] 266求調(diào)劑 +4 | 學(xué)員97LZgn 2026-03-13 | 4/200 |
|
|
[考研] 材料與化工(0856)304求B區(qū)調(diào)劑 +6 | 邱gl 2026-03-12 | 7/350 |
|
|
[考研] 一志愿山大07化學(xué) 332分 四六級(jí)已過(guò) 本科山東雙非 求調(diào)劑! +3 | 不想理你 2026-03-12 | 3/150 |
|
|
[考研] 0817化學(xué)工程與技術(shù)考研312分調(diào)劑 +3 | T123 tt 2026-03-12 | 3/150 |
|
|
[考研] 290求調(diào)劑 +3 | ADT 2026-03-13 | 3/150 |
|
|
[考研] 333求調(diào)劑 +3 | 152697 2026-03-12 | 4/200 |
|