Formatting the plot command
조회 수: 2 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (3개)
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.
댓글 수: 0
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!