Adjust intervals of x-axis in the plot!
22 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hey all,
I have SI and Date which I want to plot them. The Date is in a monthly format from 1989 to 2018 (360 months). I haven't any idea why the x interval divided into 5 years by Matlab:
But I want to set it in the monthly format.
Also, any idea how to get rid of the green line? I don't want it and I don't know why it is showing today? Yesterday I haven't this problem (the green line didn't show yesterday)
Any advice highly appreciated.
%plot vector
plot(Date,SI, 'linewidth',1.5)
xlabel('time step')
%Modify "time step"
ylabel('Precipitation')
4 comentarios
Rik
el 4 de Feb. de 2020
Even after rotating the ticks they will not be readable.
What release are you using?
Respuesta aceptada
Rik
el 4 de Feb. de 2020
You can directly set the tick locations with the xticks function. Since your variable is already a datetime (and not datenum), you don't need the datetick function.
S=load('Date.mat');
Date=S.Date;
S=load('SI.mat');
SI=S.SI;
%since the last 11 columns of SI are empty, let's remove them
SI=SI(:,1);
f=figure(1);clf(f)
plot(Date,SI, 'linewidth',1.5)
xlabel('time step')
ylabel('Standardized Precipitation Index')
xticks(Date(1:12:end))
ax=gca;
set(ax,'XTickLabelRotation',45)
Más respuestas (0)
Ver también
Categorías
Más información sobre Dates and Time en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!