TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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 am trying to add minor yticks on my axis based on the end values of a ybar stacked plot. Here is where I'm at:

Year    Far           Near      Sd
2012    1.7786e+01    31.762    88
2013    6.2690e+01    153.828   48
2014    2.9644e+01    25.0714   13
    enlarge x limits=0.15,
    enlarge y limits={upper, value=0.15},
    ybar stacked, bar width=1.5em,
    point meta=explicit,
    every node near coord/.style={
    nodes near coords align=center,
    yticklabel style={xshift=-10pt},
    minor ytick=data,
    grid = minor
\addplot table [y=Far] \datatableD;
\addplot table [y=Near] \datatableD;
\addplot[nodes near coords*={\footnotesize $(\pgfmathprintnumber\pgfplotspointmeta)$}, white, color=black, draw=none] table [y expr=0, meta=Sd] \datatableD;

Unfortunately, it looks like minor ytick=data returns a list of values from the column Far, but not for the sum Far + Near, any ideas ?

In the MWE, 3 minor ticks are added for y = 17, 29, 62. I would need the minor ticks to be added at y = 17 + 31, 29 + 25, 62 + 153 instead.

share|improve this question
Would you mind showing a mock-up of your desired final result? Thanks! – Alenanno Oct 17 '13 at 9:33
I edited the original post, I hope it is more clear now. – BigDawg Oct 17 '13 at 9:39

I can give a statement to explain the issue. Others may contribute work-arounds.

By design, minor ytick=data results in tick labels for y coordinates of the first plot (only).

While this is reasonable for normal plots, it is ... unexpected (and perhaps wrong) for stacked plots.

Nevertheless, you need to create the list of required tick labels manually; the magic value data is of no use in this context.

I'll take a note on my todo list for pgfplots to reconsider ytick=data in stacked plots.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.