如何使用pcolor绘制一个具有两个x轴的2D功能? MATLAB

时间:2016-02-07 18:45:09

标签: matlab plot

我想用两个x轴绘制一个函数。一个在底部,一个在顶部。顶部只是不同的向量。如何在顶部添加第二个x轴?

X = rand(100,100);
x = linspace(1,100,100); %bottom x axis
x2 = linspace(0.1,1,100); %top x axis
y = linspace(100,200,100);
pcolor(x,y,X);
shading interp

1 个答案:

答案 0 :(得分:1)

这可能会有所帮助,

X = rand(100,100);
x = linspace(1,100,100);
x2 = linspace(0.1,1,100);
y = linspace(100,200,100);
h2 = axes('XAxisLocation','top','XTick',linspace(0.1,1,10),'YTick',[]); 
h2_pos = get(h2,'Position'); 
h1 = axes('XTick',linspace(1,100,10),'YTick',[],...
    'Position',h2_pos);
pcolor(x,y,X,'Parent',h1);
shading interp

给出了这个,

enter image description here