change interval for xtick label
이전 댓글 표시
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개)
카테고리
도움말 센터 및 File Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!