0

I am sorry if it is a silly question or problem. In the following plot, I am getting a warning. I know it has to do something with the coordinates but can't solve it for sure. If anyone can guide me in the right direction, it would be really helpful. Thank you a lot.

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}
7
  • Use \pgfplotsset{compat=1.17}
    – Roland
    Commented Jan 25, 2022 at 8:23
  • Tried that but the warning still exists
    – t.abraham
    Commented Jan 25, 2022 at 8:36
  • For me it works. Try with commenting it out
    – Roland
    Commented Jan 25, 2022 at 10:26
  • @Roland, just to be sure: You don't get the warning by either commenting compat or downgrading the value to 1.17? Or do you mean that you get the expected resulting image? Commented Jan 25, 2022 at 10:48
  • I can confirm with PGFPlots v1.18.1 and TikZ v3.1.9a that I (also) get the warning, irrespective of the compat level, but the resulting image is as expected. Commented Jan 25, 2022 at 10:50

1 Answer 1

0

Thanks to samcarter_is_at_topanswers.xyz who helped me solve this issue. Here is what samcarter did and said.

These warnings arise because you are not only filling this path, you are also drawing the markers and the label markers in the same step.

If you decompose this into two separate steps, you can avoid the warnings:

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

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .