how to create a numeric tick label offset

10 ビュー (過去 30 日間)
Michael Ilewicz
Michael Ilewicz 2020 年 1 月 12 日
コメント済み: Michael Ilewicz 2020 年 1 月 12 日
Hi, I have a plot with large numbers on the scale e.g.
384230 384231 284232
and I would like to only show the last two digits on my final plot and have an offset noted at the side of the axis, usually where the exponent is noted so that my final tick labels look like
30 31 32 .... +284200.
I know that this is possible because I had a plot once where I struggled to get rid of the automatic function but I have been looking for a solution way to long and I can't find the right Tag. I hope someone can lead me in the right direction

採用された回答

dpb
dpb 2020 年 1 月 12 日
x=[384230 384231 284232 ...];
X0=384200; % offset value -- uses arbitrary origin
hL=plot(x-X0,y); % plot relative the offset so get desired tick labels range automagically
xl=xlim; yl=ylim; % retrieve x,y-axis limits
text(xl(end),0.95*yl(1),num2str(X0,'+%d'),'horizontalalign','right','verticalalign','top')
Salt postions to suit...just a guess. Lost access to license at least temporarily so can't test; air code...
  1 件のコメント
Michael Ilewicz
Michael Ilewicz 2020 年 1 月 12 日
This works even better:
xl=xlim;
xlabelPos=get(get(gca, 'XLabel'), 'Position');
text(xl(end),xlabelPos(2),num2str(X0,'+%d GHz'),'HorizontalAlignment','right','VerticalAlignment','top');
thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by