Two X axes with different directions
1 回表示 (過去 30 日間)
古いコメントを表示
Hi All, I need to make a plot with Two X axes with different directions (axes below)
x1 = 1:20; % axis in tau scale
x2 = x1.*(128/3); % axis in ms to s /1000
x3 = 1./(x2./1000); % axis in Hz
So the same Y values will be plotted against x2 (axis at the bottom from smallest to highest) and x3 (axis at the top from highest to smallest). Unfortunately I haven't managed to get the desired output by fdoing the following:
figure
h1 = axes
plot(x2,mean(MS_LUM_EO_FS_F(:,ini:fin)),'r'); hold on
set(h1, 'XAxisLocation', 'bottom')
h2 = axes
plot(x3,mean(MS_LUM_EO_FS_F(:,ini:fin)),'r'); hold on
set(h2, 'Xdir', 'reverse')
set(h2, 'XAxisLocation', 'top')
Any suggestions, help on how to do it?
0 件のコメント
回答 (1 件)
dpb
2022 年 10 月 18 日
x1 = 1:20; % axis in tau scale
x2 = x1.*(128/3); % axis in ms to s /1000
x3 = 1./(x2./1000); % axis in Hz
figure
hL=plot(x2,randn(size(x2)),'r');
hAx=gca;
hAx(2)=axes('Position',hAx(1).Position, ...
'XAxisLocation','top', ...
'Xdir', 'reverse', ...
'YAxisLocation','right', ...
'Color','none');
hL(2)=line(hAx(2),x3,randn(size(x3)),'Color','k');
The key thing you missed is the 'Color','none' so the second axes doesn't occlude the first.
The second requirement is either use the low-level drawing primitives such as line or (you did, just noting) set hold on or plot and the other higher-level routines will still do all their initial house-cleaning and wipe out much of what you just spent all that effort on creating...
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!