My code for tikzpicture:
\begin{tikzpicture} [domain=0:4]
\begin{axis}[ axis lines = left, xlabel = $\lambda$, ylabel = {$x$}, ]
\addplot [ fill=red, opacity=.4, domain=1:6, samples=100, color=red, thick, mark=none ] {sqrt((0.1*x^(8)+x^(6)+0.3*x^(2)+3)/(x^(8)))} -- (axis cs:0,40) \closedcycle;
\addlegendentry{$D(\lambda)$}
\addplot [ fill=blue, opacity=.4, domain=1:6, samples=100, color=blue, thick, mark=none ] {sqrt((0.1*x^(8)+x^(6)/3+0.1*x^(2)+5/3)/(x^(8)))} -- (axis cs:0,40) \closedcycle;
\addlegendentry{$f(\lambda)$}
\addplot [ domain=1:6, fill=yellow!25, opacity=.4, samples=100, color=green, thick, mark=none ] {sqrt((0.1*x^(8)-x^(6)-0.3*x^(2)-1)/(x^(8)))} \closedcycle;
\addlegendentry{$g(\lambda)$}
\end{axis}
\end{tikzpicture}
is giving a weird diagonal at right:
Why is it happening? How could I obtain a straight line under the legends?


-- (axis cs:0,40), which is very high up but not above the end point of the plot. – Apr 08 '19 at 09:18