2

I want to plot two data series with different y-coordinates over the same x. Therefore a second ordinate is drawn with a second axis environment. When I now limit the range to be drawn, the gray tick lines of the second plot overlay the black axis line of the first one. Is there a way to adjust this or to change the color of the tick lines to black (workaround, but would be okay for me). See the following minimal code sample and the cropped image below.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{figure}
    \begin{tikzpicture}
    \begin{axis}[
    axis x line*=bottom,
    axis y line*=left,
    xmin=0,
    xmax=1,
    ymin=0,
    ymax=1
    ]
    \end{axis}
    \begin{axis}[
    axis x line*=top,
    axis y line*=right,
    xmin=0,
    xmax=1,
    ymin=0,
    ymax=1
    ]
    \end{axis}
    \end{tikzpicture}
\end{figure}
\end{document}

Tick line over axis line

2

Use the option every tick/.style={black} to control tick color. You can add as many specifications as you want, e.g., color, line width, ..etc.

\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{figure}
    \begin{tikzpicture}
    \begin{axis}[
    axis x line*=bottom,
    axis y line*=left,
    xmin=0,
    xmax=1,
    ymin=0,
    ymax=1
    ]
    \end{axis}
    \begin{axis}[
    axis x line*=top,
    axis y line*=right,
    every tick/.style={black},
    xmin=0,
    xmax=1,
    ymin=0,
    ymax=1
    ]
    \end{axis}
    \end{tikzpicture}
\end{figure}
\end{document}

Ultra zoomed picture:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.