问题描述
我在Matlab中遇到一些数字问题.我将条形图分为两个数字,因为我总共有171条.我首先获取了数据的上半部分(图1),然后获取了下半部分(图2).但是后来我有了Xticks的问题.现在两者都从零开始,但是我想让后半部分(图2)从86到171(或者以10为间隔,例如,从80到180).我尝试将set(gca,'XLim',[86 171]设置为第二个图形,但是发生的是那个图形中的条形图最终超出了该图形,这是我之前从未想过的...任何提示如何解决Xticks/划分数字有问题吗?
I have some problems with figures in Matlab. I divided my bar plot into two figures since I have totally 171 bars. I took the first half of the data at first (figure 1) and then the second half (figure 2). But then I got a problem with Xticks. Now both start from zero, but I would want the second half (figure 2) to be from 86 to 171 (or with intervals of 10 so that they are from 80 to 180, for instance). I tried set(gca, ‘XLim’, [86 171] to the second figure, but what happened was that bars in that figure ended up outside the figure, which I hadn’t thought before... Any hints how to solve the problem with the Xticks/dividing the figure?
我还有关于Xticks的另一个问题!我想将它们在图中向下移动,因为我在每个小节的正上方添加了文本(或实际上是对应于不同小节的其他数字).我通过"set(gcf,'Position',get(0,'Screensize'));使数字适合整个屏幕,但是Xticks应该向下移动,以使Xticks和其他数字不在每个顶部其他.我想学习如何解决这些问题,但是似乎我需要经验丰富的人的帮助!
I also have another question about Xticks! I would want to move them downwards in the figure, since I have added text (or actually other numbers which correspond to different bars) right above every bar. I made the figures to fit the whole screen by "set(gcf, 'Position', get(0,'Screensize'));", but Xticks should be moved downwards so that Xticks and and other numbers are not on top of each other. I would like to learn how to solve these problems, but it seems like I need help from someone who has more experience!
推荐答案
x刻度是由bar()
的X
参数指定的.
The x ticks are specified by the X
argument to bar()
.
n = 171;
x = randi(20, n);
subplot(2,1,1)
bar(1:85, x(1:85))
subplot(2,1,2)
bar(86:171, x(86:171))
这篇关于划分图形并处理Xticks(Matlab)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!