Bobak Digital
Bobak Digital

Reputation: 75

Exclude Date Gaps in Time Series Plot in Matlab

I'm making a time series plot of high frequency price data. My time series has quotes for each second between 8am and 4pm but skips evenings and weekends. How can I omit these gaps from my plot such that each day's price series appears to be "glued" together.

ANSWERED:

Thanks, @Shai! I went with something like this:

% price, year, month, day, hour, minute, second are all column vectors of equal length
% exactly N price quotes per trading day (8am-4pm, excluding weekends)
date = datenum([year, month, day, hour, minute, second]);
price = price;
figure;
plot(price);
tick_index = 1:N:length(date); % my ticks are placed at the start of each trading day
tick_label = datestr(date(tick_index), 6);
set(gca, 'XTick', tick_index);
set(gca, 'XTickLabel', tick_label);

I'm very new to answering questions -- if I've violated etiquette please let me know!

Upvotes: 0

Views: 1745

Answers (1)

Shai
Shai

Reputation: 114906

You can control the XTicks of your plot to hide the gaps. See this doc.

Upvotes: 1

Related Questions