4

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 !

2
  • Why do you want to use rounded corners? Just to make the axis lines rounded corners?
    – darthbith
    Mar 12, 2015 at 11:34
  • I just want the surrounding box to be rounded, I'm not sure to understand what you mean. Mar 12, 2015 at 11:38

1 Answer 1

5

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

1
  • Could this be done within the axis environment? I am able to add a frame by typing the word \begin{axis}[frame,]\end{axis}. Is there a way to make that frame have rounded corners?
    – Nick B
    Nov 9, 2023 at 2:16

You must log in to answer this question.

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