MATLAB: How to use PLOTYY with financial time series created using the Finanicial Toolbox 3.2 (R2007a)

Financial Toolbox

I would like to use PLOTYY to plot two financial time series in two different vertical axes.

Best Answer

The ability to plot financial time series using PLOTYY is not available in Financial Toolbox 3.2 (R2007a). However, it is possible to use the MATLAB plotting capabilities to plot two financial time series objects in two different vertical axes as shown in the code below:
dates = today:today+50;
values = randn(1,51);
ts3 = fints(dates', [values', 30+20*fliplr(values)']);
f = figure;
cax = newplot;
ax(1) = cax;
h1 = plot(ax(1), ts3.dates, fts2mat(ts3.series1),'b');
ticks = get(ax(1), 'xtick');
set(ax(1), 'xlim',[ts3.dates(1) ts3.dates(end)], ...
'xtick', ticks);
grid on;
datetick(ax(1),'x',1, 'keeplimits','keepticks');
ax(2) = axes('Units',get(ax(1),'Units'), ...
'Position',get(ax(1),'Position'),'Parent',get(ax(1),'Parent'));
h2 = plot(ax(2), ts3.dates, fts2mat(ts3.series2), 'r');
set(ax(2),'YAxisLocation','right','Color','none', ...
'XGrid','off','YGrid','off','Box','off');
set(ax(2), 'xlim',[ts3.dates(1) ts3.dates(end)], ...
'xtick', ticks);
set(ax(2), 'XtickLabel', []);
legend(ax(1), [h1 h2], 'series1', 'series2');