How to remove regression line from qqplot?

7 views (last 30 days)
Hello all, For some reason, i don't want the auto fitted line (red in the picture)in my Q-Q plot. Is there any function to turned it off? here is my code for the picture attached. Also, any thoughts on how to add the Confidence Intervals?
qqplot(obs_high,M1_high); hold on
plot([0 400], [0 400])
xlabel('Observed streamflow (m^3/sec)')
ylabel('simulated streamflow (m^3/sec)')
title('Model-1');

Accepted Answer

Star Strider
Star Strider on 26 Jul 2017
Return a handle from your qqplot call, then find the line you want to remove, (experiment) and set its color to 'none'.
Example
hqq = qqplot(obs_high,M1_high);
hqq(2).Color = 'none';
Note I don’t know if the Line object referred to here as ‘hgg(2)’ is the one you want.
  2 Comments
Hydro
Hydro on 26 Jul 2017
Hello Strider, Excellent, I got some ideas from your answers, here is what I have done and I got what I wanted. Many thanks. Any thoughts on the confidence interval for the Q-Q plot?
h = qqplot(obs_high, M1_high); hold on
plot([0 400], [0 400])
set(h, 'Color', 'w','MarkerEdgeColor', 'k')
xlabel('')
ylabel('Simulated streamflow (m^3/sec)')
title('Model-1')
Star Strider
Star Strider on 26 Jul 2017
Thank you. My pleasure.
The confidence intervals aren’t an option in qqplot itself, and I’m not certain how the quantiles or the regression line are calculated.
One option is to use fitlm to calculate the regression and the confidence intervals for the plot.
Example
load gas
figure(1)
hqq = qqplot(price1);
XD = hqq(1).XData;
YD = hqq(1).YData;
mdl = fitlm(XD(:),YD(:));
[ypred,yci] = predict(mdl,XD(:));
figure(2)
plot(XD, YD, '+b')
hold on
plot(XD(:),ypred,'-r', XD(:),yci,'--r')
hold off
However, the regression line is different from that calculated by qqplot, at least with these data. Since I rarely use qqplot and am not certain how it works internally, you will probably need to ask MathWorks how best to calculate the regression line and confidence intervals.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!