I've been using pgfplots for some plots. I prefer using relatively thick lines in my plots which I feel are better suited to the font I'm using in my figures, accomplished with something like line width=1pt
in the options to \begin{axis}
. However, I'm now in the process of adding a second y-axis to a plot. The pgfplots manual says that I should use set layers
. However, when I add set layers
, I lose the effect of changing the line width. Any ideas for how I can get the line width
parameter to stick to the axis lines, ticks, plot line, and so on?
While hunting around, I stumbled upon Bug in TikZ? Line width on layers which seems related, but since I'm not really a TikZ or pgfplots expert, I'm not sure how to apply the conclusion in that Q&A.
Here's a simple example using a single axis and plot, which shows the problem I'd like to overcome:
\documentclass{minimal}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{set layers} % commenting this line makes line width work
\begin{axis}[
xmin=0,
xmax=4,
line width=1pt,
every tick/.style={black}
]
\addplot {x^2};
\end{axis}
\end{tikzpicture}
\end{document}
With set layers
active (undesirable behaviour):
After commenting set layers
(what I want to see, but while using set layers
):