How can we increase/decrease the number of MinorTicks from the command line?

2 ビュー (過去 30 日間)
Emerson De Souza
Emerson De Souza 2012 年 10 月 4 日
編集済み: Paulo Teixeira 2014 年 9 月 19 日
INTRODUCTION: Hi, I use the command lines below to generate an arbitrary curve (here sinus) and plot it as a function of the hour and min:
w = 0:pi/100:2*pi;
y1 = sin(w)';
startDate = datenum('09-28-2012 09:00:00 AM');
endDate = datenum('09-28-2012 12:20:00 PM');
x = linspace(startDate,endDate,201);
DATAVECTOR=datevec(x);
h=subplot(1,1,1);
plot(x,y1)
set(h,'XTick',x)
datetick(h,'x','HH','keeplimits')
datetick(h,'x','HH:MM','keepticks')
set(gca)
set(gca,'YTick',-1.4:0.1:1.4)
set(gca,'XMinorTick','on')
set(gca,'YMinorTick','on')
GOAL: 1) Now I want to vary the number of Minor-Ticks of the x-axis between each half-hour, for example, instead of 4 ticks (current) I would wish 5 or 3 ticks.
2) I want also that the YTick be arbitrary chosen, as written in the example above, between -1.4 in steps of 0.1 until 1.4.
PROBLEM: I don't know how to increase/decrease the number of ticks via command line and for any reason the command to generate the Ytick are not working properly: it generates the 0.1-ticks but does not go to +- 1.4.
I wonder if someone could help me to fix the problem with the commands above or suggest a different way to do it.
Thank you in advance for your help
Emerson

採用された回答

Walter Roberson
Walter Roberson 2012 年 10 月 4 日
There is no documented way to control the number of minor ticks.
  2 件のコメント
Emerson De Souza
Emerson De Souza 2012 年 10 月 4 日
Thank you Walter. At least I know it is not possible.
Now, why the command line
set(gca,'YTick',-1.4:0.1:1.4)
is not functioning? The range to be displayed in the graph should be -1.4 to 1.4 and not -1 to 1. Do you know how to fix this?
Thank you in advance
Emerson
Matt Fig
Matt Fig 2012 年 10 月 4 日
ylim([-1.4,1.4])

サインインしてコメントする。

その他の回答 (1 件)

Paulo Teixeira
Paulo Teixeira 2014 年 9 月 19 日
編集済み: Paulo Teixeira 2014 年 9 月 19 日
Hi Walter Roberson,Emerson De Souza and Matt Fig
See function my_XMinorTick
This is my function for this problem.
Best regards,

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by