how to increase the number of values displayed on the X-axis matlab

36 次查看(过去 30 天)
Hi!
I have a couple of points that their y value is changing with date. When I plot it regularly it is fine but when I plot it in a subplot it automatically does not show all the dates in x axis and just show the min and max date. I was wondering how I can get Matlab to display all the points. Attached please find the plots.
Thanks :)

回答(2 个)

Image Analyst
Image Analyst 2014-9-11
That's probably all it thought it could comfortably fit. Look up tick marks and tick labels in the help to see how you can manually set them with the set(gca, 'XTick'...) and set(gca, 'XTickLabel',.....) function calls.
  1 个评论
maryam
maryam 2014-9-12
I actually tried to input the x-axis through "set(gca,'XTick',...)" but it did not work and I guess it is because I am using datetick('x',6) ..

请先登录,再进行评论。


Joseph Cheng
Joseph Cheng 2014-9-11
you'll have to do something like this after you create the subplot.
newLim = get(gca,'XLim');
newx = linspace(newLim(1), newLim(2), 10);
set(gca,'XTick', newx);
datetick(gca,'x','HH:MM:SS','keepticks');
you'll have to play around with the number of ticks created with the linspace due to the limited space to display the day/time.

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by