For example, type the following at the command line:
x=[1,2,3];y=[1e6,2e6,3e6];figure;plot(x,y);
As you can see, a "x10^6" exponent label has been automatically added at the top of the y-axis.
Unfortunately, if a plot or subplot is narrow or the title is long, or both, then the default position of the exponent label can annoyingly overlap the title.
Is there any way to control the exponent label? I would greatly appreciate any help with the following questions:
1) Can the default position and/or orientation of the exponent label be changed so that it doesn't overlap plot titles?
2) If (1) is not possible, or very awkward, can the exponent simply be turned off? If so, I can then probably calculate an equivalent exponent and insert it as a string into the axis label.
P.S. I anticipate that some may suggest that instead of going to the trouble of moving or turning off the exponent label, I should move the title to accommodate it. However, I can already do this so may I kindly request suggestions for exponent label control only please!
Thanks to anyone who can help!
> Is there any way to control the exponent label?
No, other than turning it off.
> I would greatly
> appreciate any help with the following questions:
>
> 1) Can the default position and/or orientation of the exponent label be
> changed so that it doesn't overlap plot titles?
No.
> 2) If (1) is not possible, or very awkward, can the exponent simply be
> turned off? If so, I can then probably calculate an equivalent exponent
> and insert it as a string into the axis label.
Yes. If the [xy]ticklabelmode is 'manual' then the exponent is not added to
that axes. [xy]ticklabelmode is automatically set to 'manual' if you set
[xy]ticklabel yourself.
Is the syntax for this: set(gca,'XTickLabelMode','manual')
Because it doesn't seem to have worked. The exponent is still there, unfortunately.
If you want to do it by setting the label mode, then
You have to set XTickLabelMode or YTickLabelMode before you produce the graph,
and you have to have "hold on" in effect or else the automatic cla() that is
done will reset the mode. Labels will still be produced automatically but they
many take on unexpected values.
You are better off setting the XTickLabel or YTickLabel variables manually.
For example,
h = plot(1:10,exp(1:10));
set(gca,'YTick',2.^(10:16),'YTickLabel',num2str(2.^(10:16).'))
Thanks for the suggestions.
I'll have to work out how to do your suggestion for data that is unknown before the plotting, so I'll have to define the ticks and labels carefully, but I should be able to work it out.
>> h = plot(1:10,exp(1:10));
>> set(gca,'YTick',2.^(10:16),'YTickLabel',num2str(2.^(10:16).'))
> I'll have to work out how to do your suggestion for data that is unknown
> before the plotting, so I'll have to define the ticks and labels
> carefully, but I should be able to work it out.
h = plot(1:10,exp(1:10));
set(gca,'YTickLabel',num2str(get(gca,'YTick').'))