新浪博客

【原创】更改Matlab 坐标轴标注成科学计数法 + 移动指数到坐标轴上方

2014-08-22 22:51阅读:
%% ***********************[Random Test]***********************
%*******************[Change Matlab axis label to Exponential + move the exponet above the axis]*********************************
plot([0 1],[0 .02])
oldLabels = str2num(get(gca,'YTickLabel'));
scale = 10^2;newLabels = num2str(oldLabels*scale);
set(gca,'YTickLabel',newLabels,'units','normalized');
posAxes = get(gca,'position');
textBox = annotation('textbox','linestyle','none','string',['x 10\it^{' sprintf('%0.2f',log10(1./scale)) '}']);
posAn = get(textBox,'position');
set(textBox,'position',[posAxes(1) posAxes(2)+posAxes(4) posAn(3) posAn(4)],'VerticalAlignment','cap');
%% ***********************[Random Test]***********************


Src link: http://www.mathworks.co.uk/matlabcentral/news
reader/view_thread/112386

我的更多文章

下载客户端阅读体验更佳

APP专享