9
$\begingroup$

I am having difficulties to select the right way to visualize data. Let's say we have bookstores that sells books, and every book has at least one category.

For a bookstore, if we count all the categories of books, we acquire a histogram that shows the number of books that falls into a specific category for that bookstore.

I want to visualize the bookstore behavior, I want to see if they favor a category over other categories. I don't want to see if they are favoring sci-fi all together, but I want to see if they are treating every category equally or not.

I have ~1M bookstores.

I have thought of 4 methods:

  1. Sample the data, show only 500 bookstore's histograms. Show them in 5 separate pages using 10x10 grid. Example of a 4x4 grid: multiple histograms 1 http://i37.tinypic.com/2aes2uo.jpg2.

  2. Same as #1. But this time sort x axis values according to their count desc, so if there is a favoring it will be seen easily.

  3. Imagine putting the histograms in #2 together like a deck and showing them in 3D. Something like this: 3D histogram

  4. Instead of using third axis suing color to represent colors, so using a heatmap (2D histogram): 2D histogram If generally bookstores prefer some categories to others it will be displayed as a nice gradient from left to right.

Do you have any other visualization ideas/tools to represent multiple histograms?

$\endgroup$
  • 4
    $\begingroup$ I think you mean bar charts rather than histograms $\endgroup$ – Rob Hyndman Aug 5 '10 at 10:09
  • $\begingroup$ @Rob: Isn't histogram a special type of bar chart that represents a frequency distribution? I am trying to visualize category frequencies for many bookstores. $\endgroup$ – nimcap Aug 5 '10 at 10:28
  • 1
    $\begingroup$ @nimcap No, because histogram is over a continuous variable, and book category is a categorical variable. $\endgroup$ – user88 Aug 5 '10 at 10:46
  • $\begingroup$ @mbq Let's say a book store has 3 books, and their categories are: B1:[c1, c2, c3] B2:[c1, c3] B3:[c1, c4]. When we aggregate the category counts we get [c1 x 3, c2 x 1, c3 x 2, c4 x 1]. Isn't this enough to generate a histogram? $\endgroup$ – nimcap Aug 5 '10 at 10:56
  • 2
    $\begingroup$ @nimcap No, it is enough to generate a bar chart. Histogram can be done for instance for a price of a book. $\endgroup$ – user88 Aug 5 '10 at 11:13
12
$\begingroup$

As you have found out there are no easy answers to your question!

I presume that you interested in finding strange or different book stores? If this is the case then you could try things like PCA (see the wikipedia cluster analysis page for more details).

To give you an idea, consider this example. You have 26 bookshops (with names A, B,..Z). All bookshops are similar, except:

  1. Shop Z sells only a few History books.
  2. Shops O-Y sell more romance books than average.

A principal components plot highlights these shops for further investigation.

Here's some sample R code:

> d = data.frame(Romance = rpois(26, 50), Horror = rpois(26, 100), 
               Science = rpois(26, 75), History = rpois(26, 125))
> rownames(d) = LETTERS
#Alter a few shops
> d[15:25,][1] = rpois(11,150)
> d[26,][4] = rpois(1, 10)
#look at the data
> head(d, 2)
       Romance Horror Science History
 A      36    107      62     139
 B      47     93      64     118
> books.PC.cov = prcomp(d)
> books.scores.cov = predict(books.PC.cov)
# Plot of PC1 vs PC2
> plot(books.scores.cov[,1],books.scores.cov[,2],
       xlab="PC 1",ylab="PC 2", pch=NA)
> text(books.scores.cov[,1],books.scores.cov[,2],labels=LETTERS)

This gives the following plot:

PCA plot http://img265.imageshack.us/img265/7263/tmplx.jpg

Notice that:

  1. Shop z is an outlying point.
  2. The others shops form two distinct groups.

Other possibilities

You could also look at GGobi, I've never used it, but it looks interesting.

$\endgroup$
  • $\begingroup$ Thank you for your valuable answer. Situation is hard to describe even in my native language :) Let me try. I am not interested if bookstores are favoring particular categories but I want to see if they favor categories. Actually this is what I am expecting. Let's say I have 3 bookstores (B1, B2, B3) and 4 categories (C1, C2, C3, C4). These are their sales data: B1(1, 1, 20, 20) B2(90, 1, 1, 1), B3(1, 1, 1, 30). Looking at this data I can tell they favor some categories to others. But if data was like B1(20, 30, 20, 20) B2(90, 100, 100, 100), B3(30, 30, 40, 40) I cant say that. $\endgroup$ – nimcap Aug 5 '10 at 10:53
  • $\begingroup$ In my example, shops O-Y favour romance books. This is why these shops are in a distinct group in the PC plot. $\endgroup$ – csgillespie Aug 5 '10 at 13:00
  • 2
    $\begingroup$ I voted this up as a good general answer but as a practical answer, dealing with that many data points is going to be brutal. $\endgroup$ – John Aug 5 '10 at 15:16
  • 1
    $\begingroup$ +1 This is certainly not what OP wants, still it is certainly what she/he should want. $\endgroup$ – user88 Aug 5 '10 at 16:39
  • 1
    $\begingroup$ +1 Nice example of a "down-to-Earth" application of PCA. $\endgroup$ – nico Aug 9 '10 at 10:49
3
$\begingroup$

I would suggest something that hasn't got a defined name (probably "parallel plot") and looks like this:

alt text

Basically you plot all counts for all bookstores as points over categories listed on x axis and connect the results from each bookstore with a line. Still this may be too tangled for 1M lines, though. The concept comes from GGobi which was already mentioned by csgillespie.

$\endgroup$
  • 1
    $\begingroup$ Parallel plots depend heavily on the "right" ordering of variables, so for too many categories this will become tedious. And the correct source seems to be A.Inselberg, 1981. $\endgroup$ – Benjamin Bannier Aug 5 '10 at 11:44
  • 3
    $\begingroup$ They're called parallel coordinate plots: en.wikipedia.org/wiki/Parallel_coordinates $\endgroup$ – Simon Byrne Aug 5 '10 at 12:12
  • $\begingroup$ @Simon thanks; @honk I agree, this is one reason why I don't use them. $\endgroup$ – user88 Aug 5 '10 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.