Formatting the plot command

2 visualizzazioni (ultimi 30 giorni)
u-will-neva-no
u-will-neva-no il 29 Dic 2012
Hi everyone, I currently have values on the x and y axis which are all to the power of 1 x 10^10. I would like this value to be next to each number next to the ticks. For example, on my x axis I have the numbers 1,2,3 at the ticks and at the end it has x10^10. Is there a way to format the axis so that it looks something like 1 x 10^10 2x10^10 3x10^10 ?
Thank you

Risposte (3)

per isakson
per isakson il 29 Dic 2012
There is no simple way to do that. However, it can be done with the help of the property, YTickLabel, of the handle graphic object, axes. The doc says:
XTickLabel, YTickLabel, ZTickLabel
string
Tick labels. A matrix of strings to use as labels for tick marks along the
respective axis. These labels replace the numeric labels generated by MATLAB.
If you do not specify enough text labels for all the tick marks, MATLAB uses
all of the labels specified, then reuses the specified labels.

José-Luis
José-Luis il 30 Dic 2012
xVals = 1e10:1e10:1e11;
aH = axes;
plot(aH,xVals,rand(10,1));
set(gca,'XTickLabel',sprintf('%2.0e|',xVals));
Please see
doc sprintf
for other possible label formats.

Jan
Jan il 30 Dic 2012

Community Treasure Hunt

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

Start Hunting!

Translated by