0

Is there a way to hide the first two curves, so only the Total is shown?

Unfortunately, forget plot only excludes a curve from being listed in the legend.

\documentclass{standalone}

\RequirePackage{pgfplots}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[stack plots=y,
    legend pos=outer north east,
    minor x tick num=1,
    minor y tick num=1,
    ymin=0,
    grid=both,
    ] 
        \addplot [forget plot, line width=0pt] coordinates {(0,1) (1,1) (2,2) (3,2)};  % HIDE from graph but use for Total
        \addplot [forget plot, line width=0pt] coordinates {(0,1) (1,1) (2,2) (3,2)};  % HIDE from graph but use for Total
        \addplot [line width=2pt, mark=*] coordinates {(0,1) (1,1) (2,2) (3,2)}; 

        \legend{Total}
    \end{axis} 
\end{tikzpicture}

\end{document}

Like to hide two curves to only show the Total

Even with line width=0pt, those lines are still visible...

Any help is appreciated. Thanks!

1

You can use draw=none:

\documentclass{standalone}

\RequirePackage{pgfplots}

\begin{document}

\begin{tikzpicture}
    \begin{axis}[stack plots=y,
    legend pos=outer north east,
    minor x tick num=1,
    minor y tick num=1,
    ymin=0,
    grid=both,
    ] 
        \addplot [forget plot, draw=none] coordinates {(0,1) (1,1) (2,2) (3,2)};  % HIDE from graph but use for Total
        \addplot [forget plot, draw=none] coordinates {(0,1) (1,1) (2,2) (3,2)};  % HIDE from graph but use for Total
        \addplot [line width=2pt, mark=*] coordinates {(0,1) (1,1) (2,2) (3,2)}; 

        \legend{Total}
    \end{axis} 
\end{tikzpicture}

\end{document}

enter image description here

  • Yay! Thanks!! That was too easy :-) – gilu Feb 22 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.