plotting data with x-axis as date read from matrix, but not all dates appear on the figure

3 visualizaciones (últimos 30 días)
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 :

Respuesta aceptada

abdullah alzaqebah
abdullah alzaqebah el 22 de Mayo de 2020
Editada: abdullah alzaqebah el 22 de Mayo de 2020
solved
i used the following code:
and i get this figure
plot(datetime(BBcountry(2:end,1)),cc,'DisplayName','alg','Color', 'blue','LineWidth',1),grid on,grid minor;
xlim([datenum(BBcountry(2,1)) datenum(BBcountry(end,1))])
DateString = (BBcountry(2:end,1));
datenum(DateString);
set(gca, 'XTick', datenum(DateString))
datetick('x','dd-mmm','keepticks');
ax = gca;
ax.XTickLabelRotation = 90;

Más respuestas (0)

Categorías

Más información sobre Calendar en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by