8

I want the y-axis labels to be labeled 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10,000, …

PGFplots insists on keeping the 10^-notation in the following minimal example.

\documentclass[border=5mm]{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[y tick label style={/pgf/number format/fixed},
grid=both,
major grid style={black!50},xlabel={x},ylabel={y}]

\addplot[only marks, mark size=4pt,mark=triangle,fill,black] coordinates{
(0.000001, 13.5e3)
(0.0000024, 11.975e3)
(0.004, 4340)
(1 , 3840)
(10  , 2550)
(100 ,  2357)
(257, 2290)
(315, 2280)};

\end{loglogaxis}
\end{tikzpicture}
\end{document} 
8
  • 1
    Hi, welcome to TeX.SX. Does this help? tex.stackexchange.com/questions/29926/… (Edit: Sorry, that was perhaps not so relevant.) Commented Nov 7, 2013 at 21:26
  • 1
    The ticks from log axes are typeset a little bit differently and in fact have two to three options (the base, the exponent itself and how the exponent is typeset). That is related: Having tick labels like 1, 10, 10^2, 10^3, Commented Nov 7, 2013 at 21:40
  • 1
    There's an option for that: log ticks with fixed point, see e.g. here. Commented Nov 7, 2013 at 21:47
  • @TomBombadil Which is unfortunately not listed in the Ticks chapter of the manual … Commented Nov 7, 2013 at 21:50
  • 1
    @Qrrbrbirlbel: It's in the number formatting section (which makes sense in a way, since it doesn't affect the placement of the ticks, only the formatting of the numbers)
    – Jake
    Commented Nov 7, 2013 at 21:51

1 Answer 1

9

To have both axes in logarithmic scale, but print the labels for only one of them in fixed point format, you can use the approach from pgfplots log ticks with fixed point: only for one axis?:

\documentclass[border=5mm]{article}
\usepackage{pgfplots}

\pgfplotsset{
  log x ticks with fixed point/.style={
      xticklabel={
        \pgfkeys{/pgf/fpu=true}
        \pgfmathparse{exp(\tick)}%
        \pgfmathprintnumber[fixed relative, precision=3]{\pgfmathresult}
        \pgfkeys{/pgf/fpu=false}
      }
  },
  log y ticks with fixed point/.style={
      yticklabel={
        \pgfkeys{/pgf/fpu=true}
        \pgfmathparse{exp(\tick)}%
        \pgfmathprintnumber[fixed relative, precision=3]{\pgfmathresult}
        \pgfkeys{/pgf/fpu=false}
      }
  }
}

\pgfplotsset{compat=1.9}

\begin{document}
\begin{tikzpicture}
\begin{loglogaxis}[
log y ticks with fixed point,
ytick={2000,4000,8000,16000},
grid=both,
major grid style={black!50},xlabel={x},ylabel={y}]

\addplot[only marks, mark size=4pt,mark=triangle,fill,black] coordinates{
(0.000001, 13.5e3)
(0.0000024, 11.975e3)
(0.004, 4340)
(1 , 3840)
(10  , 2550)
(100 ,  2357)
(257, 2290)
(315, 2280)};

\end{loglogaxis}
\end{tikzpicture}
\end{document} 
2
  • Your solution worked -- once I commented out \pgfplotsset{compat=1.9}
    – user39678
    Commented Nov 7, 2013 at 22:07
  • 2
    You should set that to whatever version you're using, it makes new features available.
    – Jake
    Commented Nov 7, 2013 at 22:12

You must log in to answer this question.

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