**Timely Portfolio**, and kindly contributed to R-bloggers)

*for background please see prior posts Application of Horizon Plots, **Horizon Plot Already Available*,* and **Cubism Horizon Charts in R*

Some feedback has led me to think that I might have been a little ambitious with my last post on horizon charts. I thought it might be helpful to quickly provide an overview on horizon charts. Since I am not a visualization expert, I will try to compile the best examples and tutorials that I have found. At the end, I will do a step by step walkthrough of the construction of a horizon chart in R.

Below is a great talk in its entirety by Mike Bostock. For the discussion on horizon charts, skip to the 11:20 mark.

Mike Bostock @ Square talks about Time Series Visualization from Librato on Vimeo.

Fortunately, Mike also provides the interactive example from the video demonstrating the construction of a horizon chart from an area chart. I have embedded it below (see https://bl.ocks.org/1483226 for the full example from the original source).

This quick YouTube clip from Panopticon all the way back in 2009 also does a very nice job explaining construction. If you learn better from reading, a short paper from Hannes Reijner of Panopticon Software covers the same material.

Jeffrey Heer of Stanford University with Nicholas Kong and Maneesh Agrawala from University of California, Berkeley, investigate the effectiveness of horizon plots and make some recommendations for their use. The chart below also offers another explanation of the steps in building a horizon plot.

They recommend and conclude

Layered Bands Are Beneficial As Chart Size Decreases

We found that dividing a chart into layered bands reliably increased estimation time and increased estimation error at constant chart heights. However, we also found that 2-band mirrored charts led to better estimation accuracies for chart heights less than 24 pixels (6.8 mm on our displays). For larger chart sizes, we advise scaling 1-band mirrored charts. For smaller sizes, we advise adding layered bands.

Extending the horizon into healthcare, here is an interesting project using horizon graphs for visualization of diabetes care.

## HorizonVis

## Interactive Visual Exploration of Multivariate Medical Measurements in Diabetes Care

Lead / Contact

Wolfgang AignerTeam

Wolfgang Aigner, Vienna University of Technology

Michael Atanasov, HTBL Krems

Alexander Rind, Vienna University of Technology

Philipp Schindler, HTBL Krems

Reinhardt Wenzina, HTBL KremsPartners

Vienna University of Technology, Institute of Software Technology & Interactive Systems

HTBL Krems, Department of Information Technology

**Now For My Own Attempt at Explaining**

If we use yesterday’s example of a 200 day moving average system where you enter when above the moving average and exit when below, we might like to see a standard time series plot like this one.

From TimelyPortfolio |

In a simple world with only one asset or stock, this might be sufficient. However, we probably will have multiple instruments that we would like to monitor, and dedicating this much height per instrument will require lots of space. Ideally, we could condense each of these plots, so that we could see many at a time.

In the first step toward condensing, we could extract just the information that is most meaningful, which I consider to be the percent above or below the moving average.

From TimelyPortfolio |

We might then try an area chart to better depict above or below 0.

From TimelyPortfolio |

I’m sure you are wondering though when we will start reducing height and saving space. We could start by changing all the negative values to positive values, and add color to represent positive or negative. This means we cut our chart height by about 1/2.

From TimelyPortfolio |

However, we need much more efficiency, so let’s separate the chart into bands.

From TimelyPortfolio |

Is there any potential way of separating each of these bands and then recombining them to save space? Let’s look at each band separately.

Band 1 (0 to 10%)

From TimelyPortfolio |

Band 2 (10% to 20%)

From TimelyPortfolio |

Band 3 (20% to 30%)

From TimelyPortfolio |

Band 4 (30% to 40%) exceeding 3 bands is not recommended

From TimelyPortfolio |

Notice that similar to a heat map, the band colors increase in intensity and opaqueness as their values increase. If we layer each band on top of each other, we get a horizon plot, and we can reduce the original chart by 1/6 or even more without significant loss of information.

From TimelyPortfolio |

I hope this helps explain why we might use horizon plots and how to make them. If nothing else, maybe you will have learned some lattice techniques in R.

R code in GIST (do raw for copy/paste):

**leave a comment**for the author, please follow the link and comment on their blog:

**Timely Portfolio**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...