划分图形并处理 Xticks (Matlab)

发布于 2024-12-11 17:42:24 字数 483 浏览 0 评论 0原文

我在 Matlab 中的数字方面遇到一些问题。由于我总共有 171 个条形图,因此我将条形图分成了两个数字。我首先取了前半部分的数据(图1),然后取了后半部分的数据(图2)。但后来我遇到了 Xticks 的问题。现在两者都从零开始,但我希望后半部分(图 2)从 86 到 171(或者以 10 为间隔,以便它们从 80 到 180,例如)。我尝试 set(gca, 'XLim', [86 171] 到第二个数字,但发生的情况是该图中的条形最终超出了该数字,这是我之前没有想到的......任何有关如何解决该问题的提示Xticks/划分图形的问题?

我还有关于 Xticks 的另一个问题!我想将它们在图中向下移动,因为我在每个条形的正上方添加了文本(或实际上对应于不同条形的其他数字)。使数字为通过“set(gcf, 'Position', get(0,'Screensize'));”来适应整个屏幕,但 Xticks 应该向下移动,以便 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?

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潇烟暮雨 2024-12-18 17:42:24

x 刻度由 bar()X 参数指定。

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))

在此处输入图像描述

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))

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文