# Warning with deprecated style option

After the user Jake helped me create a functionallines style Defining a new command for making functional lines / package my final version can be shown below.

I am very happy with the output, however the code produces a bunch of warnings:

Now from my understanding of the code, the code indeed uses

every axis plot/.style={ ... }


So why does it generate the warnings?

• Is the a way (except using the silence package) to fix these warnings?

# Code

\documentclass{standalone}

\usepackage{pgfplots,xparse}

\pgfplotsset{
compat = 1.15,
shift down/.style={
y filter/.code={\pgfmathparse{\pgfmathresult*(#1)}}
},
shift down/.default=1,
positive/.style={
no markers,
red
},
negative/.style={
no markers,
blue
},
/tikz/function label/.style={
anchor=east
},
step functionallinenumber/.code={
\stepcounter{functionallinenumber}
},
title entries/.initial={}
}

\makeatletter
\newcommand\functionallineOrigin[4][\@empty]{
\edef\plots{
\noexpand\addplot [negative, shift down=#3, forget plot] {#2<0};
\noexpand\addplot [positive, shift down=#3, forget plot] {#2>0};
}
\plots
\node at (axis cs:\pgfkeysvalueof{/pgfplots/xmin},#3) [function label] {%
\ifx#1\@empty%
$#2$%
\else%
$#1$%
\fi
};

\pgfplotsinvokeforeach {#4} {
\node at (axis cs:##1,#3) [
fill=white,
inner sep=1pt,
declare function={x=##1;} % Set 'x' to current position
] {%
\pgfkeys{/pgf/fpu}% Use the fpu library, because it doesn't throw an error for divide by zero, but sets result to +/- inf
\pgfmathparse{#2}%
\pgfmathfloatifflags{\pgfmathresult}{0}{0}{x}% Check whether result is zero. The \hspace is necessary because of a bug in the fpu library. (Update 11 June 2012: Doesn't seem to be the case anymore, the \hspace can be removed)
\pgfkeys{/pgf/fpu=false}%
};
}
}

\newcommand{\undefinedSymbol}{$\times$}
\NewDocumentCommand{\functionalline}{O{#2} m m m g}{
\edef\plots{
\noexpand\addplot [negative, shift down=#3, forget plot] {#2<0};
\noexpand\addplot [positive, shift down=#3, forget plot] {#2>0};
}
\plots
\node at (axis cs:\pgfkeysvalueof{/pgfplots/xmin},#3) [function label] {$#1$};

\IfNoValueTF{#5}{%
\pgfplotsinvokeforeach {#4} {
% Set 'x' to current position
\node at (axis cs:##1,#3) [ fill=white, inner sep=1pt, declare function={x=##1;}
] {%
\pgfkeys{/pgf/fpu}% Use the fpu library, because it doesn't throw an error for divide by zero, but sets result to +/- inf
\pgfmathparse{#2}%
\pgfmathfloatifflags{\pgfmathresult}{0}{0}{\undefinedSymbol}% Check whether result is zero.
\pgfkeys{/pgf/fpu=false}%
};
}}{
\pgfplotsinvokeforeach {#4} {
\node at (axis cs:##1,#3) [fill=white, inner sep=1pt] {0};
}
\pgfplotsinvokeforeach {#5} {
\node at (axis cs:##1,#3) [fill=white, inner sep=1pt] {\undefinedSymbol};
}
}
}

\newenvironment{functionallines}[3][]{
\begin{tikzpicture}[
every axis plot/.style={restrict y to domain=0.5:inf},
]
\begin{axis}[
extra x ticks = {#2},
grid=none,
xticklabel pos=right,
hide y axis,
x axis line style={draw=none},
every tick label/.style={
anchor=base,
yshift=1ex,
gray!50
},
every extra x tick/.style={
every tick label/.style={
anchor=base,
yshift=1ex,
inner xsep=0pt,
fill=white,
text=black
}
},
extra x tick style={grid=major},
xtick pos=right,
major tick length=0pt,
enlarge x limits=false,
enlarge y limits={abs=0.75},
domain=#3,
samples=100,
y = -0.5cm,
clip=false,
#1
]
}{
\coordinate (bottom right) at (rel axis cs:1,0);
\coordinate (top right) at (rel axis cs:1,1);
\end{axis}
\draw [-latex] (top right-|current bounding box.west) -- (top right) node [right] {$x$};
\draw (bottom right) -- (bottom right-|current bounding box.west);
\end{tikzpicture}
}

\begin{document}

\begin{functionallines}[
extra x tick labels={$0$,$8$},
xtick = {-4,-2,0,2,4,6,8,10,12},
extra x ticks = {0.01,8},
]{}{-4.9:12.9}
\functionalline[a]{x}{1}{0.01}{}
\functionalline[a\phantom{^2}-8\phantom{a}]{x - 8}{2}{8}{}
\functionalline[a^2 - 8a]{x^2 - 8*x}{3}{0.01,8}{}
\end{functionallines}

\end{document}

• Well, the warning is very clear, your use of every axis plot is depreciated and will probably be removed at some point in the future. It is even telling you what to use instead. – daleif Dec 19 '19 at 12:31
• @daleif I tried to write every axis plot/.append style = { ... } before asking this question, is there something else I need to do? Sorry for not understanding! – N3buchadnezzar Dec 19 '19 at 12:35

Let's examine the error message carefully:

Loading deprecated style option /tikz/every axis plot. Please replace '\tikzstyle{every axis plot}' with '\pgfplotsset{every axis plot/.style={}}' (or '\pgfplotsset{every axis plot/.append style={}}').

There is one misleading part because you don't use the obsolete \tikzstyle macro, but the message says that /tikz/every axis plot is obsolete and should be replaced with \pgfplotsset{every axis plot/.style={...}} or with the variant using .append style. What's the difference?

Well, \pgfplotsset uses \pgfqkeys to set keys under /pgfplots, not under /tikz. Thus, instead of using the /tikz/every axis plot key, you need to use /pgfplots/every axis plot. So, you (a priori) simply need to replace:

\begin{tikzpicture}[
every axis plot/.style={restrict y to domain=0.5:inf},
]


with

\begin{tikzpicture}[
/pgfplots/every axis plot/.style={restrict y to domain=0.5:inf},
]


in lines 87-89. Alternatively, you should be able to fix the problem this way:

\begin{tikzpicture}
\pgfplotsset{every axis plot/.style={restrict y to domain=0.5:inf}}
...


Like with most TikZ macros and environments, PGF keys passed in the optional argument of the tikzpicture environment use a default path of /tikz: that is why the original code uses the /tikz/every axis plot key.

Now, if you try this, you'll see that the output is not the same as before the fix. Thus, the obsolete /tikz/every axis plot and the new /pgfplots/every axis plot key don't behave the same way. In order to obtain the same output as with /tikz/every axis plot, it appears that /pgfplots/every axis plot has to be used after the y filter from the shift down style (restrict y to domain is an y filter in pgfplots-speak). Here is one way that preserves the original output (I also removed dead code from your example and set compat level to 1.16):

\documentclass{standalone}

\usepackage{pgfplots,xparse}

\pgfplotsset{
compat = 1.16,
shift down/.style={
y filter/.code={\pgfmathparse{\pgfmathresult*(#1)}}
},
shift down/.default=1,
positive/.style={
no markers,
red
},
negative/.style={
no markers,
blue
},
/tikz/function label/.style={
anchor=east
},
step functionallinenumber/.code={
\stepcounter{functionallinenumber}
},
title entries/.initial={}
}

\newcommand{\undefinedSymbol}{$\times$}

\NewDocumentCommand{\functionalline}{O{#2} m m m g}{
\edef\plots{
\noexpand\addplot [negative, shift down=#3, forget plot,
restrict y to domain=0.5:inf] {#2<0};
\noexpand\addplot [positive, shift down=#3, forget plot,
restrict y to domain=0.5:inf] {#2>0};
}
\plots
\node at (axis cs:\pgfkeysvalueof{/pgfplots/xmin},#3) [function label] {$#1$};

\IfNoValueTF{#5}{%
\pgfplotsinvokeforeach {#4} {
% Set 'x' to current position
\node at (axis cs:##1,#3) [ fill=white, inner sep=1pt, declare function={x=##1;}
] {%
\pgfkeys{/pgf/fpu}% Use the fpu library, because it doesn't throw an error for divide by zero, but sets result to +/- inf
\pgfmathparse{#2}%
\pgfmathfloatifflags{\pgfmathresult}{0}{0}{\undefinedSymbol}% Check whether result is zero.
\pgfkeys{/pgf/fpu=false}%
};
}}{
\pgfplotsinvokeforeach {#4} {
\node at (axis cs:##1,#3) [fill=white, inner sep=1pt] {0};
}
\pgfplotsinvokeforeach {#5} {
\node at (axis cs:##1,#3) [fill=white, inner sep=1pt] {\undefinedSymbol};
}
}
}

\newenvironment{functionallines}[3][]{
\begin{tikzpicture}
\begin{axis}[
extra x ticks = {#2},
grid=none,
xticklabel pos=right,
hide y axis,
x axis line style={draw=none},
every tick label/.style={
anchor=base,
yshift=1ex,
gray!50
},
every extra x tick/.style={
every tick label/.style={
anchor=base,
yshift=1ex,
inner xsep=0pt,
fill=white,
text=black
}
},
extra x tick style={grid=major},
xtick pos=right,
major tick length=0pt,
enlarge x limits=false,
enlarge y limits={abs=0.75},
domain=#3,
samples=100,
y = -0.5cm,
clip=false,
#1
]
}{
\coordinate (bottom right) at (rel axis cs:1,0);
\coordinate (top right) at (rel axis cs:1,1);
\end{axis}
\draw [-latex] (top right-|current bounding box.west) -- (top right) node [right] {$x$};
\draw (bottom right) -- (bottom right-|current bounding box.west);
\end{tikzpicture}
}

\begin{document}

\begin{functionallines}[
extra x tick labels={$0$,$8$},
xtick = {-4,-2,0,2,4,6,8,10,12},
extra x ticks = {0.01,8},
]{}{-4.9:12.9}
\functionalline[a]{x}{1}{0.01}{}
\functionalline[a\phantom{^2}-8\phantom{a}]{x - 8}{2}{8}{}
\functionalline[a^2 - 8a]{x^2 - 8*x}{3}{0.01,8}{}
\end{functionallines}

\end{document}


• I tried both methods and they both lead to unwanted artifacts on my end. i.imgur.com/su2CqXK.png Am I doing something wrong / are you sure it produces the desired output? I only tried on Overleaf if that matters. – N3buchadnezzar Dec 19 '19 at 13:55
• Well, this is what the code produces. The question is about the warning, I explained why you have the warning and how to cleanly get rid of it. – frougon Dec 19 '19 at 13:57
• That is imho a bit of an pedantic answer =p Do I really need to specify "How can i fix my warnings while still keeping the same output" in my question title? It should be clear that the same output as before is desired. In the most extreme case just removing everything related to the environment functionallines / package pgfplots would also "fix" (remove) the warning. But would you say it would answer my question? However, I am glad that through your answer I now better understand the warning. Alas, I feel no closer to fixing it properly. – N3buchadnezzar Dec 19 '19 at 14:01
• @frougon I also tried that, but after seeing the output I had to remove my answer. – egreg Dec 19 '19 at 14:06
• @egreg Apparently, /tikz/every axis plot and /pgfplots/every axis plot don't behave the same. My latest edit uses restrict y to domain=0.5:inf after the other y filter used (via the shift down style); this preserves the original output. – frougon Dec 19 '19 at 15:02