MATLAB: Xtixks in 2d plot xticks in 2d plot hi,i have a problem to fix xticks in 2d plot. i have a time series from 1990,01 up to 2020,03;when i plot my data ,the xaxis is full of date,how i could specify the date will be shown in x axis. appreciate in advance Best Answer datetick seems a good place to start. Otherwise you can see if the xtickformat function suits your need. Related SolutionsMATLAB: Plot empties after using datetick clc;clear; close allstartDate = datenum('01-01-2009');endDate = datenum('12-31-2009');xData = linspace(startDate,endDate,10);% changed to match size of dataplot(xData,rand(10));%set(gca,'XTick',xData); %maybe not necessary?datetick('x','dd-mmm','keepticks'); MATLAB: Problem with xlim when having date Hi Behzad,xlim sets the absolute max and min of the graph that you're looking at. To set the interval for grid lines, use the xticks command.For your needs, use this with the datetick command:% Define specific five year spacing of ticks for the 27 years of interestxtks = linspace(startdate_A,enddate_A,27);plot(dt_A, DATA_A);xticks(xtks); % Set ticks for axisxlim([startdate_A,enddate_A]) % Set limitsdatetick('x','yyyy','keepticks');grid on Related QuestionAdding datenum to plotsHow to show date on xaxis
Best Answer