The reason your colors of the axis and your plot and legends dont go together is because you are changing the default color of the plot after using plotyy (i.e. plotyy plot y1 and y2 axis using the default colors blue and green and then you set the colors of the plots to 'g' and 'r')
Change your code in the first example to :
set(H1, 'LineWidth', 3);
set(H2, 'LineWidth', 3);
************************
In the second example you are trying to plot multiple yy data ont he same axis and plotyy is usually never happy with that since you have different y limits ( you re trying 3, so you can plot the ts1 and ts2 together that have limits between 900 and 1000 on left y axis and the ts3 with limits around 100 on right y axis
modified code as follows: ts1 = timeseries();%ts1 > ts2 ts2 = timeseries();
for t = 1: 1000
thisT = now;
ts1 = addsample(ts1,'Data', 1000 + randn(1),'Time', thisT);
ts2 = addsample(ts2,'Data', 900 + randn(1),'Time', thisT);
ts3 = ts1 - ts2;
from = thisT - (10 / (24*60*60)); %just load 10s of data
ts1 = getsampleusingtime(ts1, from, thisT);
ts2 = getsampleusingtime(ts2, from, thisT);
ts3 = getsampleusingtime(ts3, from, thisT);
ts1andts2.Data=[ts1.Data,ts2.Data]; % concatenate ts1 and ts2
myTime = ts1.Time;
[AX,H1,H2] = plotyy(myTime,ts1andts2.Data, myTime, ts3.Data);
set(get(AX(1),'Ylabel'),'String','\bf ts1 and ts2');
set(get(AX(2),'Ylabel'),'String','\bf ts3');
%ylim(AX(2), [floor(min(ts3.Data)) ceil(max(ts3.Data))])
set(H1, 'LineWidth', 3);
set(H2, 'LineWidth', 3);
datetick(AX(1), 'x');
datetick(AX(2), 'x');
linkaxes(AX,'x');
grid on;
xlabel('');
str = {'ts1','ts2','ts3'};
% legend([H1 H3 H2], str, 'Location','Best');
legend(str)
drawnow;
pause(1);
end