More X ticks for subplots

1 回表示 (過去 30 日間)
xander fong
xander fong 2015 年 7 月 22 日
回答済み: Azzi Abdelmalek 2015 年 7 月 22 日
Hello, I have a figure with 10 subplots on them. The x axis is made from a matrix is Datetime format. However,there are only two ticks on the x axis. How do I increase the amount of ticks and corresponding ticklabels?

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 7 月 22 日
Look at this example
%---------Example---------------
t=0:0.1:10;
y=[sin(t);cos(t);t.^2];
for k=1:3
subplot(1,3,k)
plot(t,y(k,:))
end
%---------------------------
h=findobj(gcf,'type','axes')
n=6 % numbers of ticks
for k=1:3
a=get(h(k),'xlim')
xt=linspace(a(1),a(2),n)
set(h(k),'xtick',xt)
end

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by