Create multiple x axis for pcolor plot

I tried the method with http://au.mathworks.com/help/matlab/creating_plots/graph-with-multiple-x-axes-and-y-axes.html. However, it does not work for pcolor plot, as one of my x axis is the inverse of the other. I also have tried to used hold on and hold off, that went no where as well.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 1월 31일

0 개 추천

Perhaps File Exchange and set one of the axes handles to have 'Xdir', 'reverse' ?

댓글 수: 2

Sam Lo
Sam Lo 2016년 1월 31일
Inverse as the other x-axis is 1/(original x-axis) times some scalar. I am not sure if only by reverse will do the trick.
Sounds like the old frequency vs wavelength conversion. That should not be a problem.
For example,
c = 50;
x = sort(rand(1,75));
y = sin(x);
plot(x,y)
ax1 = gca;
minx = min(x);
maxx = max(x);
set(ax1,'xlim',[minx maxx])
ax1ylim = get(ax1, 'ylim');
ax2 = axes('Position', get(ax1,'Position'), 'xaxislocation', 'top', 'color', 'none');
set(ax2, 'xlim', [c./maxx c./minx], 'xdir', 'reverse', 'ytick', [], 'ylim', ax1ylim)
uistack(ax2, 'bottom')
Sending the second axis to the bottom is to prevent interference with any datatips.
The above code does not link the axes together for zooming or panning, and makes no attempt to create a combined datatip that shows both version of the x axis.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

질문:

2016년 1월 31일

댓글:

2016년 1월 31일

Community Treasure Hunt

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

Start Hunting!

Translated by