TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to create a stacked bar plot where the data is loaded using the pgfplotstableread command. I want to use a logarithmic scale rather than a normal scale. However, when I change theaxis environment to semilogyaxis, pdfplots gives an error:

! Package pgfplots Error: Sorry, pgfplots expects stacked plots to have exactly the same number of coordinates. Unfortunately, I encountered at plot with DIFF ERENT NUMBERS OF COORDINATES. Please verify that 1. no point has been dropped b y coordinate filters (for example log(0) or so) and 2. all plots have the same number of coordinates..

The problem lies with the fact that I have zero values in my dataset. These values do not represent missing values, but I think that pgfplots thinks they are.

How can I correctly plot my data (containing zero values) on a logarithmic scale?

\usepackage{pgfplots, pgfplotstable}

X   Gp  C1  C2  Name        Zn      Pb
1   1A  0.2 3   Duracem     47.2    12
2   1A  0.2 3   Technocem   0      11
3   1A  0.2 3   Alipre      28      13
5   1A  0.2 8   Duracem     16.2    12

    axis lines*=left, ymajorgrids,
    width=5cm, height=6cm,
    ybar stacked,
    bar width=8pt,
    xticklabels from table={\datatable}{Name},
    xticklabel style={rotate=90,xshift=-10ex,anchor=mid east}
\addplot table [x=X, y=Zn] {\datatable}; \addlegendentry{Zn}
\addplot table [x=X, y=Pb] {\datatable}; \addlegendentry{Pb}

share|improve this question
you can compile your stuff if you replace 0 by (say) 1e-16 and ymin=0 by ymin=1. But the key question is... what does stacking logs mean? I am not sure by heart, but I believe it will stack logs, that is: multiply numbers. Please double-check that the log is actually useful here. – Christian Feuersänger May 30 '14 at 10:19
Thank you, that works! I understand your comment related to stacking logs, I didn't think about that. I'll do some experiments to see whether the logarithmic scale is indeed the right choice. – eider May 30 '14 at 10:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.