[Tex/LaTex] ny package to create bullet gauge graphs

graphics

I am looking for a package to create bullet gauge graphs, but I couldn't find any.

A bullet graph looks like this:

enter image description here

and an ample description/specification can be found here

It is available in Mathematica 9 (see here)

Is it possible create this kind of graphs in a easy way with TeX (like Matehmatica 9 or similar)?

Best Answer

This can be relatively easily achieved using PGFPlots. I've written a small macro that is called like this:

\bulletgauge[title={\bfseries{\large Revenue}\\1000 USD}]{275}{260}{300,250,150}

to create this:

The optional argument can be used to pass normal PGFPlots options to the axis environment used internally.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots, pgfplotstable}

\definecolor{ylgnbu1}{RGB}{237, 248, 177}
\definecolor{ylgnbu2}{RGB}{127, 205, 187}
\definecolor{ylgnbu3}{RGB}{44, 127, 184}

\pgfplotscreateplotcyclelist{bullet}{
{fill=ylgnbu1, draw=none},
{fill=ylgnbu2, draw=none},
{fill=ylgnbu3, draw=none},
}

\pgfplotstableread[col sep=semicolon]{
Label;  Sublabel;   Measure;    CompMeasure; Range1; Range2; Range3
Revenue 2005 YTD;   USD;    260;    255;150;250;300
}\datatable

\newcommand{\bulletgauge}[4][]{
    \begin{tikzpicture}
    \begin{axis}[
        y=1.5ex,
        xtick pos=left,
        ytick=\empty,
        xmin=0, xmax=300,
        enlarge y limits={abs=0ex},
        tick align=outside,
        axis on top,
        every axis title/.style={
            at={(rel axis cs:0,0.5)},
            anchor=east,
            align=right,
            xshift=-1em
        },
        #1
    ]
    \pgfplotsinvokeforeach{#4}{
        \pgfplotsset{cycle list name=bullet}
        \addplot +[xbar, bar width=3ex] coordinates {(##1,0)};
    }
    \addplot [fill=black, xbar, bar width=1ex] coordinates {(#2,0)};    
    \addplot [mark=|, mark options={very thick}, mark size=1.25ex] coordinates {(#3,0)};
    \end{axis}
    \end{tikzpicture}
}


\begin{document}
\bulletgauge[title={\bfseries{\large Revenue}\\1000 USD}]{275}{260}{300,250,150}
\end{document}