I've spent all day on this and have found no solution; I'm trying to graph a cosine plot (y(x) = 2cos(x/4)) and while I have tried to plot the actual function out on pgfplot, the graph just wouldn't work, with either the negative values going on the positive side, or the curves not showing up at all so I decided to just plot the coordinates instead which has technically almost worked.
The problem is that my coordinates are pi values but they don't show up as such in the plot and I've tried xticklabels but that isn't working either.
This is my code:
\begin{tikzpicture}
\begin{axis}
[grid=both,
minor tick num=4,
grid style={line width=.2pt, draw=black!10},
major grid style={line width=.4pt,draw=black!50},
axis lines=middle,
enlargelimits={abs=0.1},
width=12cm, height=9cm
]
axis y line=middle,
axis x line=middle,
\addplot[smooth, blue] coordinates {
(-6*pi, 0)
(-4*pi, -2)
(-2*pi, 0)
(0, 2)
(2*pi, 0)
(4*pi, -2)
(6*pi, 0)
};
\end{axis}
\end{tikzpicture}
What I'm trying to figure out is how to change the values on the x-axis to pi while keeping those on the y-axis as they are.
Thanks!


xticklabel={\pgfmathparse{\tick/pi}$\pgfmathprintnumber[precision=0]{\pgfmathresult}\pi$}– Torbjørn T. Jun 20 '20 at 22:27