\closedcycle 包 pgf 警告:未指定可在输入时填充的路径

\closedcycle 包 pgf 警告:未指定可在输入时填充的路径

如果这是一个愚蠢的问题,我很抱歉。在下面的情节中,我收到了警告。我知道它与坐标有关,但无法确定解决它。如果有人能给我指明正确的方向,那将非常有帮助。非常感谢。

包 pgf 警告:未指定可在输入行 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}

答案1

谢谢samcarter_is_at_topanswers.xyz谁帮我解决了这个问题。以下是 samcarter 所做的和所说的。

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

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

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

在此处输入图片描述

相关内容