how to create a numeric tick label offset

9 visualizaciones (últimos 30 días)
Michael Ilewicz
Michael Ilewicz el 12 de En. de 2020
Comentada: Michael Ilewicz el 12 de En. de 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

Respuesta aceptada

dpb
dpb el 12 de En. de 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
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 comentario
Michael Ilewicz
Michael Ilewicz el 12 de En. de 2020
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

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by