Formatting the plot command

2 ビュー (過去 30 日間)
u-will-neva-no
u-will-neva-no 2012 年 12 月 29 日
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

回答 (3 件)

per isakson
per isakson 2012 年 12 月 29 日
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 2012 年 12 月 30 日
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 2012 年 12 月 30 日

カテゴリ

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