xAxis of plot starts when no data is available

1 view (last 30 days)
I want to plot price data with the corresponding date on the x axis.
figure(1);
Datum = table2array(Dates(p_date_c:p_date_c+z,1));
plot(Datum, pricedata)
xlabel('Time')
ylabel('Total Return')
The "Datum" is in datetime format and ranges from 31-Dec-2019 to 31-Dec-2020, and so do the pricedata! pricedata and Datum has the same length. But why does the plot starts in Oct-2019, and not Dec-2019?
Thanks in advance

Accepted Answer

Walter Roberson
Walter Roberson on 22 Jan 2021
MATLAB is trying for "nice" tick marks. With the datetime values you are giving it, everything except December 31 2019 fits in nicely to create ticks by quarters. Going back to Oct 2019 is extending back one further quarter in order to accomodate the December 31 2019 entry.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!