Scientific notation values to the y axis label based on original data
显示 更早的评论
Hey! I would like to automatically have the y-axis label updated based on the input values for the variable y. In this case I would like the line "-5" in the y-axis label replaced by "10^-5" (with the -5 shown as an exponent).
Thanks in advance for any help!
if true
% code
x=[1:3];
y=[.00002 .00004 .00006];
figure;
plot(x,y);
ylabexp=floor(log10(y(1)));
ylab = {'\uparrow';'\epsilon /';ylabexp;'M^{-1}'};
yh = ylabel(ylab);
set(yh,'rot',0)
ylabh2 = get(gca,'YLabel');
set(ylabh2,'Position',get(ylabh2,'Position') - [.1 0 0])
end
4 个评论
Reid
2014-5-23
dpb
2014-5-23
Simplest is to insert to blank spaces in front of the first line of code in a new paragraph (ie, with a blank line in front of code)
Star Strider
2014-5-24
编辑:Star Strider
2014-5-24
I tried to run your code but couldn’t.
- PLEASE format your code — use the ‘[{}Code]’ button
- what is ‘yval’?
- Y not use semilogy?
Reid
2014-5-24
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Axis Labels 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!