4

I want some minor ticks on the y axis, but it doesn't work. I already tried minor y ticks num but it didn't help. Thank you in advance.

\documentclass[11pt,a4paper,oneside ]{article}
\usepackage[USenglish, german,ngerman]{babel}
\usepackage[utf8x]{luainputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[a4paper, top=2cm, bottom=2cm,left=1cm , right =1cm]{geometry}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[
            xmin = 0,
            height=10cm,
            width=18cm,
            ymode=log,
            grid = both,
          ]

  coordinates{
   (1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20) 
  };

  \end{axis} 
\end{tikzpicture}

\end{document}
nickpapior
  • 17,275
DerJFK
  • 473
  • Thank you for the quick answer, but that is not what I meant. For example the following pictures from http://tex.stackexchange.com/questions/37782/pgfplots-ticklabel-format-logarithmic-scale ,... here you see major an minor ticks, and that is not happening in my example above :( – DerJFK Jun 19 '14 at 21:46

2 Answers2

3

The ticks are being placed but are being obscured by the grid. So you can either disable the grid, or change the style of the ticks so that they are more prominent:

enter image description here

Code:

\documentclass[11pt,a4paper,oneside ]{article}
\usepackage[USenglish, german,ngerman]{babel}
\usepackage[utf8x]{luainputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[a4paper, top=2cm, bottom=2cm,left=1cm , right =1cm]{geometry}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document} \begin{tikzpicture} \begin{axis}[ xmin = 0, height=10cm, width=18cm, ymode=log, grid = both, y tick style={ultra thick, draw=red}, x tick style={ultra thick, draw=blue}, ]

coordinates{ (1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20) };

\end{axis} \end{tikzpicture}

\end{document}

Peter Grill
  • 223,288
  • also thanks for the quick answer, but I am looking for the minor ticks. Like here: http://tex.stackexchange.com/questions/37782/pgfplots-ticklabel-format-logarithmic-scale there some small ticks between the big ticks ,.. sorry if my explanation was confusing – DerJFK Jun 19 '14 at 21:49
1

The minor y tick num key is not available for logarithmic axis (see manual version 1.10, page 276)

But if you enlarge the range of your y axis you will get the minor ticks or grid. Use something like enlarge y limits=0.4to get

enter image description here

Code:

\documentclass[11pt,a4paper,oneside ]{article}
\usepackage[USenglish, german,ngerman]{babel}
\usepackage[utf8x]{luainputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage[a4paper, top=2cm, bottom=2cm,left=1cm , right =1cm]{geometry}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{pgfplotstable}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[
            xmin = 0,
            height=10cm,
            width=18cm,
            ymode=log,
            grid = both,
            major y grid style=red,
            enlarge y limits=.4
          ]
\addplot  coordinates{
   (1,2)(2,4)(3,6)(4,8)(5,10)(6,12)(7,14)(8,16)(9,18)(10,20) 
  };

  \end{axis} 
\end{tikzpicture}

\end{document}

Or if you want minor ticks instead of the minor grid you can use

grid = major,
minor y tick style={red,very thick},
enlarge y limits=.4

enter image description here

Alternativly you can set ymin=1,ymax=100 to enlarge the y range:

grid = major,
minor y tick style={red,very thick},
ymin=1,ymax=100

enter image description here

If you don't want a larger y range you can use the key ytickten={0,...,10} to set the major ticks explicitly only at 10^0,10^1,...,10^10.Then there will be only one major y line at 10^1 in your example.

grid = both,
major y grid style=red,
ytickten={0,...,10}

enter image description here

esdd
  • 85,675