# Why does the plot of a continuous function have gaps [duplicate]

Plot[-s*(-q^2/(2*s) +
q*(p - 1)/
s + (-(p*s - 2*s + 1)/(2*s^2) -
Sqrt [s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log[(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) -
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s -
2*s)] - (-(p*s - 2*s + 1)/(2*s^2) -
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log [q + (2*
s^2*(-(p*s - 2*s + 1)/(2*s^2) -
Sqrt [s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s -
2*s)] + (-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log [(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s -
2*s)] - (-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log[q + (2*
s^2*(-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s -
2*s)]), {q, 0, 1}, PlotRange -> All, Exclusions -> None]


As comment said, you should provide values for p and s so one can reproduce the result. But while waiting for coeffee, I tried few random values for p and s and reproduced the problem. The fix is to add Chop as this is result of small complex values that shows up.

ClearAll[p, s, q];
p = .1;
s = .2;
f := -s*(-q^2/(2*s) +
q*(p - 1)/
s + (-(p*s - 2*s + 1)/(2*s^2) -
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log[(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) -
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s -
2*s)] - (-(p*s - 2*s + 1)/(2*s^2) -
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log[q + (2*
s^2*(-(p*s - 2*s + 1)/(2*s^2) -
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s -
2*s)] + (-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log[(2*s^2*(-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s -
2*s)] - (-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4))*
Log[q + (2*
s^2*(-(p*s - 2*s + 1)/(2*s^2) +
Sqrt[s^5*(s - 1)]*(p - 2)/(2*s^4)) + 1)/(p*s - 2*s)]);
Plot[f, {q, 0, 1}, PlotRange -> All, Exclusions -> None]


Now see what happens when adding Chop

 Plot[Chop[f], {q, 0, 1}, PlotRange -> All, Exclusions -> None]


• Chop is not needed if you use exact values for your p and s: Plot[Evaluate[(expr /. {p -> 1/10, s -> 1/5})], {q, 0, 1}] – Bob Hanlon Mar 23 '19 at 2:45
• @BobHanlon That is true. OP must have used real values. – Nasser Mar 23 '19 at 2:48

Better plot the real part with Re (nulling the spurious imaginary part) instead of using Chop (nulling the spurious imaginary part if it is below a threshold; but also nulling the real part if it gets too small):

Plot[Re[f], {q, 0, 1}, PlotRange -> All, Exclusions -> None]