plotting data with x-axis as date read from matrix, but not all dates appear on the figure
Ältere Kommentare anzeigen
the matrix contains dates like:
'4/19/2020' [19]
'4/20/2020' [20]
'4/21/2020' [21]
'4/22/2020' [22]
'4/23/2020' [23]
'4/24/2020' [24]
'4/25/2020' [25]
'4/26/2020' [26]
'4/27/2020' [27]
'4/28/2020' [28]
'4/29/2020' [29]
'4/30/2020' [30]
'5/1/2020' [ 1]
'5/2/2020' [ 2]
'5/3/2020' [ 3]
am trying to plot the data with respect of the date in the matrix, cc contains the values from BBcountry, and the second column of BBcountry contain the dates ordered in ascending order, first row contains the minimum date and the last row contains the maximum one. the figure shows 30-april as max tick in x-axis while the data contains 3-may
i used
plot(datetime(BBcountry(2:end,1)),cc,'DisplayName','alg','Color', 'blue','LineWidth',1),grid on,grid minor;
datetick('x','dd-mmm-yy','keepticks');
xlim([datenum(BBcountry(2,1)) datenum(BBcountry(end,1))])
ax = gca;
ax.XTickLabelRotation = 45;
xticks=get(gca,'xtick');
set(gca,'xticklabel',cellstr(datestr(xticks))')
when i ran it iget :

Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Dates and Time finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
