Latex: \closedcycle Package pgf 警告:没有指定可在输入中填写的路径

Latex: \closedcycle Package pgf Warning: No path specified that can be filled on input

在下面的情节中,我收到了警告。我知道它必须对坐标做些什么,但不能确定地解决它。如果有人能指导我正确的方向,那将非常有帮助。

Package pgf Warning: No path specified that can be filled on input line 55.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{float}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\title{StackExchange}
\author{M. Tahasanul Ibrahim}
\date{January 2022}

\begin{document}

    \begin{figure}[H]
        \centering
        \begin{tikzpicture}
            \begin{axis}
                [
                    % ybar,
                    % xmin=-1,xmax=10,
                    % ymin=0,ymax=18,
                    % xlabel={Data Value},
                    % ylabel={Occurrence/Frequency}]
                    xlabel= {Data Value}, 
                    ylabel= {Occurrence/Frequency},
                    enlarge x limits=0.1,
                    legend style={
                            at={(0.5,-0.15)},               
                            anchor=north,legend columns=-1
                    },
                    width=12.8cm,
                    height=8cm,
                    point meta={x*100},
                    symbolic x coords={0,1,2,3,4,5,6,7,8,9},
                    grid=both,
                    grid style={line width=.1pt, draw=gray!10},
                    major grid style={line width=.2pt,draw=gray!50},
                    % axis lines=middle,
                    minor tick num=5,
                    nodes near coords={$\pgfmathprintnumber{\pgfkeysvalueof{/data point/y}}$},
                ]
            \addplot+ [color=black, bottom color=green, top color=red] coordinates
                {
                    (0,1)
                    (1,5) 
                    (2,7) 
                    (3,12) 
                    (4,15)
                    (5,9) 
                    (6,7) 
                    (7,3) 
                    (8,0)
                    (9,1) 
                } \closedcycle;
            \end{axis}
        \end{tikzpicture}
        \caption{Area chart representing statistical data}
    \end{figure}

\end{document}

出现这些警告是因为您不仅在填充这条路径,还在同一步骤中绘制标记和标签标记。

如果将其分解为两个单独的步骤,则可以避免警告:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{float}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

\title{StackExchange}
\author{M. Tahasanul Ibrahim}
\date{January 2022}

\begin{document}

    \begin{figure}[H]
        \centering
        \begin{tikzpicture}
            \begin{axis}
                [
                    % ybar,
                    % xmin=-1,xmax=10,
                    % ymin=0,ymax=18,
                    % xlabel={Data Value},
                    % ylabel={Occurrence/Frequency}]
                    xlabel= {Data Value}, 
                    ylabel= {Occurrence/Frequency},
                    enlarge x limits=0.1,
                    legend style={
                            at={(0.5,-0.15)},               
                            anchor=north,legend columns=-1
                    },
                    width=12.8cm,
                    height=8cm,
                    point meta={x*100},
                    symbolic x coords={0,1,2,3,4,5,6,7,8,9},
                    grid=both,
                    grid style={line width=.1pt, draw=gray!10},
                    major grid style={line width=.2pt,draw=gray!50},
                    % axis lines=middle,
                    minor tick num=5,
%                    nodes near coords={$\pgfmathprintnumber{\pgfkeysvalueof{/data point/y}}$},
                ]
            \addplot [color=black, bottom color=green, top color=red] coordinates
                {
                    (0,1)
                    (1,5) 
                    (2,7) 
                    (3,12) 
                    (4,15)
                    (5,9) 
                    (6,7) 
                    (7,3) 
                    (8,0)
                    (9,1) 
                } \closedcycle;
                
            \addplot+[black,mark=*,nodes near coords={$\pgfmathprintnumber{\pgfkeysvalueof{/data point/y}}$},] coordinates
                {
                    (0,1)
                    (1,5) 
                    (2,7) 
                    (3,12) 
                    (4,15)
                    (5,9) 
                    (6,7) 
                    (7,3) 
                    (8,0)
                    (9,1) 
                };                
            \end{axis}
        \end{tikzpicture}
        \caption{Area chart representing statistical data}
    \end{figure}

\end{document}