刻度的强制指数格式类似于MATLAB,它会自动执行 [英] Force exponential format of ticks LIKE MATLAB does it automatically

查看:129
本文介绍了刻度的强制指数格式类似于MATLAB,它会自动执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个情节.在第一个绘图中,y轴的值最高为30000.因此,Matlab在该绘图上方用"3"和"x10 ^ 4"标记了该轴,而不是"30000".在第二个图中,y值直到10000.由于该值太低而无法自动切换为指数格式,因此它的确打印为"10000".

I have two plots. In the first plot the values for the y-axis go up to 30000. Therefor, Matlab is labeling the axis instead of '30000' with '3' and the 'x10^4' ABOVE the plot. In the second plot the y-values just go til 10000. Due to the fact that this value is too low to automatically switch to exponential format it really prints '10000'.

我想知道是否有一种方法可以强制进行指数格式化.这将导致Matlab自动执行相同格式".我问这个问题是因为我已经看到了解决方案,您可以在其中让Matlab直接将Y10标签打印为"10 ^ 3",但是我只想让它在Label上方显示为"1",在图形上方显示为"x10 ^ 3".

I would like to know if there is a way to force the exponential formatting. This will result in THE SAME FORMAT as Matlab does it automatically. I am asking this because I have seen solutions where you can make Matlab print '10^3' directly as Y-label, but I just want to have it show '1' as Label and the 'x10^3' above the plot.

下图显示了为了阐明我的问题而合并在一起的不同地块.在图像的左半部分,您可以看到如果我使用的值大于10000,Matlab会做什么.如果下图显示的话,这就是我要为下半部分所示的轴获取的格式.

The following image shows to different plots merged together just for the purpose of clarifying my question. In the left half of the image you can see what Matlab does if I am using values > 10000. And that's the kind of format I want to get for the axis shown in the second half if the image below.

推荐答案

我之所以来到这里是因为我需要类似的东西,而且我知道现在有解决方案. 也许从R2015及更高版本开始,您可以使用以下方法设置指数:

I just get here because I need something similar, and I know that now there is a solution for that. Perhaps from R2015 and newer, you can set the exponent excatly with:

ax.YAxis.Exponent = 3  % 3 is for example

或者,如果您想要完整的数字:

Or, if you want the full numbers:

ax.YAxis.Exponent = 0

ax是轴手柄.

这篇关于刻度的强制指数格式类似于MATLAB,它会自动执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆