2

I'm trying to display two linear models and their confidence intervals (made with fitlm) to a figure I created in MatLab.

LM1 = fitlm(1:5, TL_martin);
LM = fitlm(our_TL, our_data)
plot(LM,'Color','b'); 
plot(LM1,'Color','r');

I can plot these fine, and by specifying the color above I am able to change the data points to red and blue to differentiate between the two models. However, the best fit line is still red for both of them, so I am unable to distinguish between the two lines of best fit. I have tried using 'LineStyle' but when I do this the graph no longer displays a linear regression, but instead just connects each of the data points exactly.

Any recommendations?

duplode
  • 33,731
  • 7
  • 79
  • 150
Lauren
  • 23
  • 6

1 Answers1

1

plot returns handles to the created objects, namely a handle to data (the first element), fit (second element), and confidence bounds (elements 3 and 4). Using

ph = plot(LM);
set(ph(1), 'MarkerEdgeColor',  ...);
set(ph(2), 'Color',  ...);

you can adjust the colours and line styles.

zeeMonkeez
  • 5,057
  • 3
  • 33
  • 56