| 查看: 3769 | 回复: 0 | |||
[交流]
怎样在同一个图中画两个等高线图?
|
|
目的: 存在两组等高线,两组等高线有交集。将两个等高线画在同一个图中,每组等高线使用不同的colormap, 两组等高线的交集应该是两组颜色的重叠。 实现方法一 使用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 实现方法二 原则上来说,在一个figure中只能使用一种colormap,所以如果不像第一种方法定义colorbar,两组等高线的色调是一样的。解决这个问题可以采用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 |
» 猜你喜欢
存款400万可以在学校里躺平吗
已经有16人回复
拟解决的关键科学问题还要不要写
已经有7人回复
请教限项目规定
已经有3人回复
基金委咋了?2026年的指南还没有出来?
已经有10人回复
基金申报
已经有6人回复
推荐一本书
已经有13人回复
国自然申请面上模板最新2026版出了吗?
已经有17人回复
纳米粒子粒径的测量
已经有8人回复
疑惑?
已经有5人回复
计算机、0854电子信息(085401-058412)调剂
已经有5人回复

找到一些相关的精华帖子,希望有用哦~
matlab里怎么画两个自变量的二维图
已经有3人回复
请问:origin如何绘制场分布图
已经有10人回复
求助:如何在ORIGIN里把响应面的3D图和等高线图画到一个图里
已经有1人回复
求助大神,xrd扫描速率不同,能否用oringin中画在同一张图中
已经有4人回复
在matlab中用mesh画三维图存在的问题
已经有11人回复
如何实现matlab在一个图里以同一个横坐标画两个图
已经有5人回复
MATLAB将三维图和其中一个面的等高线画出来的问题,谢谢了。
已经有7人回复
fluent计算的后处理:怎么把两组不同的数据画在一个曲线图里,作对比分析用
已经有14人回复
如何在Matlab 下同一个坐标轴里画两个函数的图形,其中一个函数变化非常快
已经有5人回复
ARCGIS如何画地图等高线
已经有8人回复
怎么画电子密度图的等高线
已经有3人回复
就是用origin如何画出两个Y轴的图
已经有8人回复
请问origin里可以将三维图和其对应的等高线图做到一张图中吗?怎么做?
已经有9人回复
LaTex使用问题,帮忙画两个图标
已经有3人回复
什么软件可以画出二维色谱的等高线图和三维图?Origin可以吗?
已经有1人回复
请教一个图形如何画
已经有12人回复
【求助】怎样用origin绘制三维效应面和二维等高图
已经有7人回复
origin中横坐标同一范围内取点不同的纵坐标画到只有一个横坐标的图中
已经有3人回复
科研从小木虫开始,人人为我,我为人人











,Y(:,1),Z1); % plot the first contour
回复此楼
点击这里搜索更多相关资源