matlab - 如何更改我所有子图中的 xticks 间隔?
问题描述
我使用此代码是为了在一个图中有 6 个图。我想将所有子图的 x 轴间隔更改为 5 年 5 年。像 1990, 1995, 2000, 2005, ...事实上,我希望它们之间有空格以增加可读性。另外,我想要这个 x 厚的小字体。这是我的图:
这是我的代码:
plotMonths=[1,3,6,12,24,48].'; % list of month intervals desired for plot
plotColors=['r';'b';'k';'g';'m';'c']; % colors; use whatever desired or rgb triplet
figure;
for i=1:6
hAx(i)=subplot(2,3,i); % create subplot, save axes handle
hL(i)=plot(Date,SPI_table.("SPI_"+plotMonths(i)+"month"),plotColors(i),'linewidth',1);
xlabel('time step')
ylabel("SPI "+plotMonths(i)+"month")
xticks(Date(1:12:end))
set(hAx(i),'XTickLabelRotation',90)
end
subplot(2,3,1)
title('SPI 1')
subplot(2,3,2)
title('SPI 3')
subplot(2,3,3)
title('SPI 6')
subplot(2,3,4)
title('SPI 12')
subplot(2,3,5)
title('SPI 24')
subplot(2,3,6)
title('SPI 48')
sgt = sgtitle('Nonparametric SPI for Abadan Station','Color','red');
sgt.FontSize = 20;
我想请你帮我解决这个问题。
解决方案
试试这个
xticks( datetime( 1995:5:2020 , 1 , 1 ) )
推荐阅读
- c# - ItemsControl 组合框 selecteditem C# WPF MVVM
- android - 如何在kotlin的另一个文件中访问数组列表?
- python - Pytorch - RuntimeError: 标量类型 Long 的预期对象,但在调用 _thnn_nll_loss_forward 时为参数 #2 'target' 获得了标量类型 Float
- node.js - 如何在 Nestjs 中将文件上传到 Google 云存储?
- c# - 通过从C#中的类调用函数来显示消息
- php - Laravel Sail 是否已准备好部署
- azure - 捕获和广播群组视频通话
- javascript - 我想在表单提交时显示成功消息
- python - 我做了一个简单的代码,它应该读取我的语法(即'prt(Nice)'),但它会抛出这个:IndexError:字符串索引超出范围
- java - android底页中的RecyclerView Checkbox状态