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

76 views (last 30 days)
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 :)

Answers (2)

Image Analyst
Image Analyst on 11 Sep 2014
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 Comment
maryam
maryam on 12 Sep 2014
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) ..

Sign in to comment.


Joseph Cheng
Joseph Cheng on 11 Sep 2014
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.

Categories

Find more on Line Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!