pgfplots:隱藏圖中的曲線

pgfplots:隱藏圖中的曲線

有沒有辦法隱藏前兩條曲線,以便只顯示總計?

不幸的是,forget plot僅排除了圖例中列出的曲線。

\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}

喜歡隱藏兩條曲線以僅顯示總計

即使使用line width=0pt,這些線條仍然可見...

任何幫助表示讚賞。謝謝!

答案1

您可以使用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}

在此輸入影像描述

相關內容