Bullet Graph in R

Bullet graphs are an effective and efficient visual representation for key indicators (e.g. KPI), that were proposed by Stephen Few. I find them highly suitable to build dashboards. For this purpose I developed an implementation in R to draw such graphs.

In summary a bullet graph is a variation of a bar graph with additional references that consist of a thick line that represents the reference point (e.g. benchmark, goal, or previous value) and a background that identifies three levels (e.g. Low-Medium-High, Bad-Average-Good, etc.).

The figure below illustrates the main components, though a complete specification is available on Few’s web site.

Bullet Graph elements (from Wikipedia)

The function bulletgraph() provides a simple interface to plot a bullet graph, for instance to reproduce the example above we can use the following statements:

par(mfrow=c(2,1), mar=c(2,9,.1,1))

bulletgraph(x=270,ref=260,limits=c(0,200,250,300),
            name= "Revenue 2005 YTD",subname="(U.S. $ in thousands)",
            colored=F)

bulletgraph(x=270,ref=260,limits=c(0,200,250,300),
            name= "Revenue 2005 YTD",subname="(U.S. $ in thousands)")

Which generates the following diagram:

Bulletgraph

Example of generated bullet graph

The code is available as open-source under the GPL at:
http://softeng.polito.it/software/R/BulletGraph.R

Enjoy and let me know!

Update: added an option (colored=F) to have gray scale background (as recommended in the specification), and a subtitle to be able to reproduce the example.

Update 2: now the revised and tested code, with documentation too, is available on GitHub, here: https://github.com/mtorchiano/MTkR/wiki/Bullet-Graph

Annunci

3 thoughts on “Bullet Graph in R

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione / Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione / Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione / Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione / Modifica )

Connessione a %s...