Reputation: 167
I would like to plot one function with two x axis. One on the bottom one on the top. The top is just different vector. How to add the second x axis on the top ?
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
Upvotes: 1
Views: 252
Reputation: 4336
This might help,
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
which gives this,
Upvotes: 1