如何更改MATLAB图中轴上显示的数字的格式? [英] How to change the format of the numbers displayed on an axis in a MATLAB plot?

查看:94
本文介绍了如何更改MATLAB图中轴上显示的数字的格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实际上有3个问题:

我有一个图,其中有成千上万个数据,并且图的轴显示刻度线为.4 .8 1.0 1.2和右下角的* 10 ^ 4.这有点烦人.

I have a plot with data that is in the thousands and my plot's axis is diplaying the tick marks as .4 .8 1.0 1.2 and a *10^4 in the lower right. This is a little annoying.

除了将我的数据除以1000或hardcodig刻度线外,还有一种方法可以将刻度线从.4 * 10 ^ 4更改为4000吗?

Besides dividing my data by 1000 or hardcodig the tick marks is there a way to change to tick marks from .4*10^4 TO 4000?

看起来这应该是微不足道的,但是在浏览完该图的所有属性之后,我似乎找不到位置.

Seems like this should be trivial but aftter browsing through all of the figure's properties I can't seem to get an where.

而且...一旦我得到4000,而不是.4 * 10 ^ 4,就可以旋转刻度线标签,这样它就不会与其他标签重叠.

And...once I get 4000 to apear instead of .4*10^4 is there a way to rotate the tick mark label so it is not overlapping the other labels.

然后..您如何设置有多少个主要"刻度线?

And..how do you set how many "major" tick marks there are?

非常感谢!

ME

推荐答案

尝试以下操作:

x=[4000, 8000, 10000, 12000]; % define the x values where you want to have a tick
set(gca,'XTick',x);  % Apply the ticks to the current axes
set(gca,'XTickLabel', arrayfun(@(v) sprintf('%d',v), x, 'UniformOutput', false) ); % Define the tick labels based on the user-defined format

参考: Mathworks

关于标签旋转,看来Matlab本身并不支持这种功能,但是有人写了

In regards to the label rotation, it seems that Matlab does not support such feature by its own, but someone wrote a script for the label rotation, and you might want to give it a try.

这篇关于如何更改MATLAB图中轴上显示的数字的格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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