MATLAB Answers

how to create a numeric tick label offset

7 views (last 30 days)
Michael Ilewicz
Michael Ilewicz on 12 Jan 2020
Commented: Michael Ilewicz on 12 Jan 2020
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


Sign in to comment.

Accepted Answer

dpb on 12 Jan 2020
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
Salt postions to suit...just a guess. Lost access to license at least temporarily so can't test; air code...

  1 Comment

Michael Ilewicz
Michael Ilewicz on 12 Jan 2020
This works even better:
xlabelPos=get(get(gca, 'XLabel'), 'Position');
text(xl(end),xlabelPos(2),num2str(X0,'+%d GHz'),'HorizontalAlignment','right','VerticalAlignment','top');

Sign in to comment.

More Answers (0)

Sign in to answer this question.


Translated by