add grid lines to minor x ticks

129 ビュー (過去 30 日間)
Heidi Hirsh
Heidi Hirsh 2020 年 2 月 5 日
回答済み: Payas Bahade 2020 年 2 月 11 日
I am trying to make a plot where my x labels are weeks. I only want to label every other week, but I want x gridlines for every week. Right now I have the right number of x ticks (weekly) since I made the major ticks every 14 days and minor ticks every 7 days (see figure attached). So I think I want to set up gridlines on the minor ticks but I am not sure how to control that.
Thank you so much for any advice!
This is how I am setting up my xaxis right now:
x = datenum('June-13-2018'):n:datenum('Oct-3-2018');
xx = datenum('June-13-2018'):nn:datenum('Oct-3-2018');
set(gca, 'XTick', x);
ax = gca
ax.XAxis.MinorTick = 'on'
ax.XAxis.MinorTickValues = xx
datetick('x','mm/dd','keepticks')

回答 (1 件)

Payas Bahade
Payas Bahade 2020 年 2 月 11 日
Hi Heidi,
To add minor x ticks’ grid lines, ‘grid minor’ command can be used. For more details on grid lines, please refer this documentation link.
Hope this helps!

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by