change interval for xtick label
71 次查看(过去 30 天)
显示 更早的评论
Consider the following example:
clear all
x = (0:23).';
n = numel(x);
time = cellstr(datestr([ones(n,1)*[2012 3 10] x zeros(n,2)],'HH:MM'));
Data = rand(1,24);
plot(x,Data);
set(gca,'XTick',0:23);
set(gca,'XTickLabel',time);
Here, I can plot the change in a certain variable as a function of time (in hours). Is there a method for only showing every other hour in the x axis i.e. still show all of the data but with the ticks showing 00:00 02:00 04:00...etc.
I have tried:
set(gca,'XTick',0:2:23);
but to no avail. Any advice would be appreciated.
0 个评论
采纳的回答
Wayne King
2012-4-18
Hi, you have to do the same thing for xticklabel
set(gca,'Xtick',0:3:23)
set(gca,'XtickLabel',time(1:3:end))
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Parallel Server 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!