# Nodes Near coords hide when 0

Is it possible to hide nodes near coords in pgfplots when value = 0 ?

I have something like this.

And axis setting

\begin{axis}[
ybar,
bar width=3pt,
nodes near coords
]

• It's always a good idea to provide the community with some sample data as well as a (complete) minimal working example (MWE) - something we can copy-and-paste-and-compile. It just makes it easier to work with the problem. – Werner Mar 5 '15 at 6:43

As standard node near coordinates is \pgfmathprintnumber{\pgfplotspointmeta}. You want to run that only if \pgfplotspointmeta is non-zero. This may be tested for with \pgfmathfloatifflags as follows:

near coords={\pgfmathfloatifflags{\pgfplotspointmeta}{0}{}{\pgfmathprintnumber{\pgfplotspointmeta}}}


with 0 indicating test whether the number is equal to zero, {} being the action if it is and the final group containing the action if it is not zero.

You don't provide the code for your plot, so here is a similar case instead:

\documentclass{article}

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

\begin{document}

\begin{tikzpicture}
\begin{axis}[
ybar,
bar width=3pt,
nodes near coords={\pgfmathfloatifflags{\pgfplotspointmeta}{0}{}{\pgfmathprintnumber{\pgfplotspointmeta}}}
]