I am trying to use a solution similar to the solution proposed here to switch in a graphic the labeling of the x-axis; the MWE is this one:
\documentclass[12pt,t, fleqn,
%,handout %% "handout" for one page per slide
]{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{tikz}
\usepackage{pgfplots}\pgfplotsset{compat=1.9, width=8cm}
\tikzset{
onslide/.code args={<#1>#2}{% https://tex.stackexchange.com/a/6155/16595
\only<#1>{\pgfkeysalso{#2}}
},
alt/.code args={<#1>#2#3}{%
\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} % \pgfkeysalso doesn't change the path
},
}
\begin{document}
\begin{frame}
\frametitle{Title}
\begin{tikzpicture}[
]
\begin{axis}[
%font=\scriptsize,
xmin=-0.5, xmax=10, domain=0:10,
ymin=-1, ymax=9,
xlabel = {$t$},
xtick = {0,1,...,9},
onslide = {<2->{xticklabels={$0$,$T$,,,,,,,$nT$,},}},%
% xticklabels={$0$,$T$,,,,,,,$nT$,}, % uncomment this and it works
]
\addplot [alt={<1>{color=blue}{color=gray, thick}},
%visible on=<1>,
] {0.8*x};
\only<2->{\addplot [red, samples=200,] {0.6*x};}
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}
but it isn't working --- it seems that when I put xticklabels in the onslide conditional, the key is not recognized anymore:
! Package pgfkeys Error: I do not know the key '/tikz/xticklabels', to
which you passed '$0$,$T$,,,,,,,$nT$,', and I am going to ignore it.
Perhaps you misspelled it.
Notice that if I use the second line (the commented one, unconditional) the xticklabels is recognized.
What am I missing here?
Notice that the alt for the color works ok --- the result is
PS: I found a workaround; I can use
\only<2->{\pgfplotsset{xticklabels={$0$,$T$,,,,,,,$nT$,}}}
in the frame outside the tikzpicture and it seems to work, but nonetheless, it's not elegant... ;-)



onslide = <2->{/pgfplots/xticklabels={$0$,$T$,,,,,,,$nT$,}},%– percusse Feb 17 '17 at 21:33"\pgfkeysalso doesn't change the path"in the definition ofonslidehas /me completely confused. What about an answer? – Rmano Feb 17 '17 at 22:09\tikzsetso there is an implicit/tikz/appended to the start of the key that's why it gets confused. It doesn't change the path so/tikz/stays. Then pgfplots can't figure it out. – percusse Feb 17 '17 at 22:42\tikzsetwith\pgfplossetgives me aonslideoption I can use in theaxisenvironment. A pity that then I need differentonslidefor other things... would you write an answer so that I can accept it? – Rmano Feb 19 '17 at 16:34