[英]Removing scientific notation but with rounding in Matlab tick labels
I am plotting on a very small scale from a loop that generates a vector, data
. 我正在从一个生成矢量
data
的循环中进行非常小规模的绘图。 Anyway, the YTickLabel
is automatically in "6x10-3" format, for example. 无论如何,
YTickLabel
自动为“6x10-3”格式,例如。
data = [0.0004578945622489441 0.00154798436685536652442 0.005987463212456878422336324 0.003651558742652333624455];
plot(data)
I know I can use the following to have the full tick label displayed: 我知道我可以使用以下内容显示完整的刻度标签:
yt = get(gca,'YTick');
set(gca,'YTickLabel', sprintf('%.4f|',yt))
However, because these numbers are generated from my loop, they are very long (~20 digits) and so this displays them in full. 但是,因为这些数字是从我的循环生成的,所以它们非常长(~20位),所以这样就完整地显示了它们。 I need to somehow round my ticks?
我需要以某种方式围绕我的蜱虫? (Without doing it manually using
YTickLabel = {'0.0001', '0.0002'};
... etc.) (不使用
YTickLabel = {'0.0001', '0.0002'};
手动YTickLabel = {'0.0001', '0.0002'};
...等)
The following works for me: 以下适用于我:
set(gca, 'YTickLabel', get(gca, 'YTick'))
In Matlab R2014b you could also use 在Matlab R2014b中你也可以使用
ax = gca;
ax.YTickLabel = ax.YTick;
Either way, what this does is assign the YTick values to the YTickLabel. 无论哪种方式,这样做是将YTick值分配给YTickLabel。 Somehow that prevents scientific notation.
不知何故,这会阻止科学记数法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.