Plotting timeseries in space filling curves

Written by Jeff Heard on August 24th, 2009

Fitting many timeseries in the same area and formatting them for quick comparison is challenging and an important problem.  For example, say that you want to pick stocks in the S&P 500 that perform similarly or which respond similarly to certain numerical transformations (say they have the same trend lines or the same noise frequency).  Line graphs are inappropriate for this because they’re too visually noisy and because you can only compare easily up to down, not left to right, visually, limiting the number of graphs on the page at the same time.

For certain comparisons, we aren’t interested in the individual values of a timeseries nor its trend along time so much as we are how it relates to other timeseries in the same dataset.  For this purpose over the weekend, I created these:

timeseries

These are timeseries simply plotted along a Hilbert curve.  The 8 you see here are the first 8 stocks in alphabetical order of the S&P 500, plotted with one segment per day for all trading days in the last decade.  Blues are lower values.  Oranges are higher values.  They have each been normalized internally for their minimum and maximum prices, so the shape of the curve is more important than the maxima or minima.

In this figure, we see two glyphs that are similar: the first and the next to last.  These correspond to Agilent and Adobe, respectively.  Let’s look at their 5 year charts to see how similar they in fact are:

a

Adobe (ADBE). Source: Google Finance

Source: Google Finance

Agilent (A). Source: Google Finance

Now, despite some surface differences, you’ll note that the shapes of the graphs are indeed similar, and that when Agilent goes up, Adobe tends to go up, and when Agilent goes down, Adobe tends to as well.  Now, these two companies are unrelated in terms of market sector, so can we really say that these similarities matter?  If it were a short trend, maybe not, but this is a 5 year graph that we’re comparing here, and they’re remarkably similar to each other.  It’s worth delving deeper into.  They could be majority held by the same people, they could track for reasons that aren’t immediately obvious, they could have the many of the same people on their board of directors, or it could in the end be complete coincidence (but paradoxically predictive coincidence).

Here, by the way, for comparison is Apple, the third glyph from the Hilbert graph, shown as an area chart on the same timescale as A and ADBE:

aapl

Apple (AAPL). Source: Google Finance

One might expect, considering that the majority of Adobe’s projects run on Apple computers and a majority of Apple computers run Adobe products, that when Apple does well, Adobe does well, and vice versa.  We can see that this is not the case.  Much as the two Hilbert graphs are unrelated, AAPL and ADBE’s performance are unrelated.

Noe also that I managed to pack 8 timeseries in less space total using the Hilbert glyphs than the Google finance graphs.

And yes, by the way, this was written in Haskell using Hieroglyph.  I don’t have the code on me right now, but I’ll post it later on today when I’m in front of my personal computer.

6 Comments so far ↓

  1. Ognen says:

    You can also play with something that looks similar to cellular automaton pictures as per Stephen Wolfram. For a pic of S&P 500 returns over a period of a year see http://naniteworld.com and scroll down to the bottom of the page.

  2. Rog says:

    Erm … nice concept ‘n’ all, but a comment on the space efficency of plots… you can stack 8 stocks on a Google finance graph no problems (see website link for example)

  3. Tomasz says:

    Could you provide a link to your dataset?

  4. [...] Plotting timeseries in space filling curves | Hieroglyphics (tags: visualization data fractal) [...]

  5. Eric Shull says:

    Where do you get downloadable data like this?

  6. Jeff Heard says:

    I used the YahooQuotes package for python to download the data.

  7. Jeff Heard says:

    As you do so, the resolution available for minute changes in value decreases much quicker in Google Charts than in a setup like this. I can stack many more in this kind of chart than Google finance in the same area and achieve the same level of resolution you get in Google.

  8. [...] modeled on a space-filling curve associated with Hilbert. Such curves, it appears, have limitless magical properties, even when applied only metaphorically to arrange 256 square tiles on a [...]

Leave a Comment





2 Trackbacks / Pingbacks

  1. links for 2010-05-25 « Blarney Fellow
  2. Map of the Internet « text/x-kcd