Effacer les filtres
Effacer les filtres

Help!!! Can't figure out this error

1 vue (au cours des 30 derniers jours)
liu James
liu James le 25 Nov 2016
Réponse apportée : dbmn le 25 Nov 2016
I'm getting this error when I run the plot. "There is no DatetimeTickFormat property on the Line class." I'm trying to have x axis show the dates rather than the serial date number. Please Help
MATLAB code
if
fts1 = fints(Time,Data,{'Open','High','Low','Close'})
high = fts2mat(fts1.High)
dates=datenum(Time,'yyyy/mm/dd')
window_size=20;
output=tsmovavg(high,'s',window_size,1);
plot(dates,output,'DatetimeTickFormat','dd-MMM-yyyy');
end

Réponses (1)

dbmn
dbmn le 25 Nov 2016
There are two solutions to your problem
a) choose a format other than datenum for your dates variable, f.ex.
dates = datetime(Time,'InputFormat','yyyy/MM/dd');
b) keep the data the same but fiddle with the xlabel property
myAx = gca; % or via plothandle.Parent
n = 5; % user each n-th element
myAx.XTick = dates(1:n:end);
myAx.XTickLabel = datestr(dates(1:n:end), 'yyyy/MM/dd');

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by