3

I can't figure out a way to prevent small values showing in my labels. A problem that looked very similar to mine can be found in here. Due to my non-existent coding skills I couldn't figure out this on my own. So here is the code I've got so far:

\documentclass{article}

\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}

\definecolor{RYB1}{RGB}{128, 177, 211}
\definecolor{RYB2}{RGB}{251, 128, 114}
\definecolor{RYB3}{RGB}{190, 186, 218}
\definecolor{RYB4}{RGB}{255, 255, 179}
\definecolor{RYB5}{RGB}{141, 211, 199}
\definecolor{RYB6}{RGB}{253, 180, 98}

\pgfplotscreateplotcyclelist{ColorListBar}{
{RYB1!50!black,fill=RYB1},
{RYB2!50!black,fill=RYB2},
{RYB3!50!black,fill=RYB3},
{RYB4!50!black,fill=RYB4},
{RYB5!50!black,fill=RYB5},
{RYB6!50!black,fill=RYB6},
}

\begin{document}

    \begin{figure}[H]
\begin{center}
\begin{tikzpicture}
\pgfkeys{
     /pgf/number format/precision=2, 
    /pgf/number format/fixed zerofill=true,
    /pgf/number format/fixed
}
\begin{axis}[
ybar stacked,
bar width=9mm,
nodes near coords,
enlargelimits=0.3,
legend style={at={(0.5,-0.20)},
anchor=north,legend columns=-1},
ylabel={ylabel},
symbolic x coords={A, B, C},
xtick=data,
cycle list name=ColorListBar
]
\addplot plot coordinates {(A,0.26) (B,0.32) (C,0.32)};
\addplot plot coordinates {(A,0.28) (B,0.29) (C,0.35)};
\addplot plot coordinates {(A,0.05) (B,0) (C,0.01)};
\addplot plot coordinates {(A,0.13) (B,0.17) (C,0.17)};
\addplot plot coordinates {(A,0.06) (B,0.01) (C,0.01)};
\addplot plot coordinates {(A,0.05) (B,0.07) (C,0.01)};
\legend{1, 2, 3, 4, 5, 6}
\end{axis}
\end{tikzpicture}
\end{center}
\end{figure}
\end{document} 

This results in a Figure that looks like this: enter image description here

I would like to remove the labels that currently have the value 0.01 and thus look very cluttered. How could this be achieved?

7

It's actually the same question indeed but here is your version,

instead of just nodes near coords, you can apply a test as follows

nodes near coords = {%
    \pgfmathprintnumberto[fixed,assume math mode=true]{\pgfplotspointmeta}{\myval}%
    \pgfmathparse{\myval<0.05?:\myval}\pgfmathresult%
}

enter image description here

  • This was exactly what I was looking for and the reply speed was rather impressive. A big thank you! – Cadbon Aug 12 '14 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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