MATLAB: How to create a timeline timeline I want to have the time (e.g from january to december) on the x-axis and just location on the "y axis". Example: LOCATION location 1 x_________ x location 2 x __ x location 3 x x_xx__xxx__xxx timline jan —- juni —- dec — > 2016 Best Answer See if something like this does what you want:dnv = datenum([2016 01 00]) + cumsum(eomday(2016, 1:12)); % X-Axis Datesloc1 = datenum([2016 01 01]) + randi(364, 1, 3); % Create Dataloc2 = datenum([2016 01 01]) + randi(364, 1, 5); % Create Dataloc3 = datenum([2016 01 01]) + randi(364, 1, 7); % Create Datafigure(1)plot(loc1, 3*ones(size(loc1)), 'x')hold onplot(loc2, 2*ones(size(loc2)), 'x')plot(loc3, 1*ones(size(loc3)), 'x')hold offgridset(gca, 'XTick', dnv)datetick('x', 'mmm', 'keepticks')axis([xlim 0 4]) Related SolutionsMATLAB: Add dates in x-axis Referring the doc: datetick is useful when plotting numeric values that are serial date numbers. Days is just an array of numbers and not actually serial date numbers. Instead, use datetime to create your dates info and then plot. d1 = datetime('01/01/2020','InputFormat','dd/MM/uuuu');d2 = datetime('30/03/2020','InputFormat','dd/MM/uuuu');days = d1:1:d2; % Creates your x-axis, 90 dates from Jan 1st to March 30figure(1)plot(days,df,'b.-')grid on, axis tightdatetick('x','dd/mmm'); %datetick('x','dd') will show 90 x-axis ticks, which may not look neat in the plot MATLAB: How to align date formats dates = {'01/01/2016', '1/01/2016', '01/1/2016', '1/1/2016'};datestr(datenum(dates), 'dd/mm/yyyy') Related QuestionHow to arrenge timeseries dataWrite one year date into a excelHow to find all possible combinations for different location settingsPlotting one curve with two colors
Best Answer