how to create a second x axis with different intervals?

Hiya! I've been looking at similar questions but haven't been able to make the code work myself. I'm trying to make a scatter plot for examining fluxes with depth, where the y axis is depth, one x axis is lipid fluxes and the second x axis is carbon flux. I need the two x axes to have a different interval range. I've managed to get the first x axis but for some reason the second won't show up. This is the code I have so far:
scatter(fame1,depth1,'^')
set(gca, 'YLim',[-750 -100])
ax= gca;
ax1= ax;
ax2= ax;
ax2.XAxisLocation= 'bottom';
set(ax1, 'XAxisLocation', 'top')
set(ax1,'XTick',([0:0.25:3]));
set(ax2, 'XAxisLocation', 'bottom')
set(ax2,'XTick',([0:5:25]));
How can I get the second x axis on the bottom to show up?? Any help would be appreciated!

 采纳的回答

You've actually got three copies of the one axes handle (ax,ax1,ax2); you've never created a second axes.
hSc=scatter(rand(10,1)*2,randi([-720 -120],10,1),'^')
hAx1= gca;
hAx1.YLim=[-750 -100];
xticks(hAx1,[0:0.25:3])
hAx1.XAxisLocation= 'top';
hAx2=axes('position',hAx1.Position,'color','none');
hAx2.XAxisLocation='bottom';
xticks(hAx2,[0:5:25])
hAx2.YTick=[];
xlim(hAx2,[0 25])
box on
results in

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Data Distribution Plots 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by