[Tex/LaTex] nodes near coords with logarithmic axis: Wrong values

bar chartnodes-near-coordspgfplots

I created a horizontal bar plot to compare benchmark times. Since one of the tested components is really slow, I need a logarithmic y axis for the other values to be distinguishable. Combined with "nodes near coords" this results in the calculated values showing, instead of the original ones. Is there any way to fix this?

What it looks like:
Correct plot, wrong labels

What the values(!) should look like:
Wrong plot, correct labels

Clearly, I'm overlooking something terribly obvious. I'm just a beginner at PGFPlots, so please don't kill me. 🙂

MWE:

\documentclass[fontsize=12pt]{scrartcl}

\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}
  \begin{tikzpicture}
  \begin{axis}[ 
    width=12.5cm,
    xbar=0.1cm,
    xmin=0,
    y=0.6cm,
    bar width=0.4cm,
    xlabel={Time (ms)},
    xmode=log,
    major x tick style = transparent,
    major y tick style = transparent,
    symbolic y coords={
      {SpreadsheetGear},
      {Aspose.Cells},
      {NPOI},
      {C1.Excel},
      {Spire.XLS},
      {GemBox.Spreadsheet},
      {SmartXLS},
    },
    ytick=data,
    y dir = reverse, 
    nodes near coords,
    nodes near coords align={horizontal},
  ]

  \addplot coordinates {
      (3078.6,{Aspose.Cells})
      (10059.2,{C1.Excel})
      (28794.8,{GemBox.Spreadsheet})
      (7437079.8,{SmartXLS})
      (19975.2,{Spire.XLS})
      (573.2,{SpreadsheetGear})
      (10025.2,{NPOI})};
  \end{axis}
  \end{tikzpicture}
\end{document}

Best Answer

PGFPlots is printing the log transformed x value. To print the non transformed value, set point meta=rawx. (Similarly for ybar, use point meta=rawy to get the raw y value.)

Note that bar plots with logarithmic axes are a really bad idea, since the zero point of logarithmic plots is arbitrary and the length of the bar doesn't carry any information. A dot plot is better in this case:

\documentclass[fontsize=12pt]{scrartcl}

\usepackage{pgfplots}
\pgfplotsset{compat=1.8}

\begin{document}
  \begin{tikzpicture}
  \begin{axis}[ 
    width=12.5cm,
    %xbar=0.1cm,
    only marks,
    xmin=0,
    y=0.6cm,
    bar width=0.4cm,
    xlabel={Time (ms)},
    xmode=log,
    major x tick style = transparent,
    major y tick style = transparent,
    symbolic y coords={
      {SpreadsheetGear},
      {Aspose.Cells},
      {NPOI},
      {C1.Excel},
      {Spire.XLS},
      {GemBox.Spreadsheet},
      {SmartXLS},
    },
    ytick=data,
    y dir = reverse, 
    nodes near coords,
    nodes near coords align={horizontal},
    point meta=rawx
  ]

  \addplot coordinates {
      (3078.6,{Aspose.Cells})
      (10059.2,{C1.Excel})
      (28794.8,{GemBox.Spreadsheet})
      (7437079.8,{SmartXLS})
      (19975.2,{Spire.XLS})
      (573.2,{SpreadsheetGear})
      (10025.2,{NPOI})};
  \end{axis}
  \end{tikzpicture}
\end{document}
Related Question