0

I have a very simple logarithmic plot, but for some reason I can't manage to show the ticks in the vertical axis. Why is this happening and is there a way to know a priori how to set the axes so that logarithmic ticks always show?

\documentclass[border=0pt]{standalone}
\usepackage[dvipsnames,svgnames,table]{xcolor} % use color
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}         
    \begin{loglogaxis}[
        xlabel=DOFs,
        ymin=1e-15, ymax=10,
        xmin=100, xmax=10000,
        width = 7cm,
        legend style={at={(0, 0.)}, anchor=south west,draw=none},
    cycle list name=black white,
        every axis y label/.style={at={(current axis.west)},xshift=-30pt,rotate=90}
        ]

    \addplot [RoyalBlue, thick, mark=o, mark options={scale=1.,solid, RoyalBlue}] table{%
            121 0.08945684062706045
            341 0.0036813848097262576
            561 0.00034635822751205646
            881 2.0512221130767817e-05
            1301 7.797318160808208e-07
            1821 2.125368998262977e-08
            2441 4.5746964051472774e-10
            3161 8.682927671779316e-12
            3981 1.4744125484712826e-13
            4901 3.91582540186572e-15
    };
   \end{loglogaxis}
\end{tikzpicture}

\end{document}
  • Your example works fine here, up to date TeX Live 2017, pgfplots version 1.15. – Torbjørn T. Dec 20 '17 at 20:29
  • There isn't enough space to label them all. If you increase the height, more will become visible. I would just list the tick values. – John Kormylo Dec 20 '17 at 20:49
  • While I did add an answer, I'm not really sure if it answers your question, as you seem to say that you don't get any ticks at all (which was the reason behind my first comment, above). – Torbjørn T. Dec 20 '17 at 21:37
4

With your code I get yticks at 10^0, 10^(-5), 10^(-10) and 10^(-15). If you want yticks at every order of magnitude, you can add either ytick distance=10^1 or ytickten={-15,-14,...,1} to the axis options. That will also give you minor ticks, and makes things a bit cramped:

all ticks

If you want to remove the minor ticks, set subtickwidth=0pt in the axis options.

ytickten={-15,-13,...,1} might be better:

output with ytickten={-15,-13,...,1}

\documentclass[border=20pt]{standalone}
\usepackage[dvipsnames,svgnames,table]{xcolor} % use color
\usepackage{pgfplots}

\begin{document}

\begin{tikzpicture}         
    \begin{loglogaxis}[
        xlabel=DOFs,
        ymin=1e-15, ymax=10,
        xmin=100, xmax=10000,
        width = 7cm,
        ytick distance=10^1,
        % ytickten={-15,-13,...,1},
        % subtickwidth=0pt
        ]

    \addplot [RoyalBlue, thick, mark=o, mark options={scale=1.,solid, RoyalBlue}] table{%
            121 0.08945684062706045
            341 0.0036813848097262576
            561 0.00034635822751205646
            881 2.0512221130767817e-05
            1301 7.797318160808208e-07
            1821 2.125368998262977e-08
            2441 4.5746964051472774e-10
            3161 8.682927671779316e-12
            3981 1.4744125484712826e-13
            4901 3.91582540186572e-15
    };
   \end{loglogaxis}
\end{tikzpicture}
\end{document}
  • Ah, "distance." I kept searching for interval. – John Kormylo Dec 20 '17 at 21:38

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.