[Tex/LaTex] Pgfplots rounded corners and plot problem

pgfplotsrounded-corners

I noticed something strange recently when trying to use rounded corners in pgfplots: it totally ruins the plot. See below without rounded corners:

enter image description here

and then with rounded corners:

enter image description here

Here is a minimal example:

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}[scale=0.8,trim axis left, trim axis right]
\tikzset{every mark/.append style={scale=0.6}}
\pgfplotsset{legend style={font=\footnotesize}}

\begin{axis}[   grid=both,
            rounded corners,
            ]
    \addplot[samples=100,color=blue,very thick,smooth,domain=-10:10] {cos(x^(3))};
\end{axis}
\end{tikzpicture}

\end{document}

Thanks in advance for your ideas !

Best Answer

If you only want the axis lines to be rounded, you need to set the axis line style key. Otherwise, pgfplots applies the rounded corners style to all of the lines it draws, including the plots.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}[scale=0.8,trim axis left, trim axis right]
\tikzset{every mark/.append style={scale=0.6}}
\pgfplotsset{legend style={font=\footnotesize}}

\begin{axis}[   grid=both,
            axis line style={rounded corners},
            ]
    \addplot[samples=100,color=blue,very thick,smooth,domain=-10:10] {cos(x^(3))};
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Related Question