# Visualise significant differences in a contingency table?

I'm working with pandas and scipy, and I would like to find a quick way to visualise unusual values in a contingency table.

Say this is my contingency table:

                  wolves   lions   tigers   chickens    total
ate_zebra         14112    13891   12978    54          41035
ignored_zebra     6403     6377    6109     2637        21526
total             20515    20268   19087    2691        62561


It looks as though chickens are (mostly) vegetarian, unlike the other animals.

If I run a chi-squared test, it tells me that the chi-squared value is significant and the expected values are:

wolves      lions       tigers      chickens    total
13456.19515 13294.18296 12519.54165 1765.080242 41035
7058.804846 6973.817043 6567.458353 925.9197583 21526
20515       20268       19087       2691        62561


But what I'd really like is some way to quickly, visually identify the most significant differences from the expected values, say something like this:

Excel would be good enough, but something Python-based would would be ideal :) Or do I need to write my own algorithm to do this?

Any suggestions much appreciated.

• I may hint towards computing and presenting standardized or adjusted Pearson residuals. – ttnphns Sep 10 '14 at 7:43
• @ttnphns Thanks! That does look like the right approach. – Richard Sep 10 '14 at 16:07
• Another (somewhat related) possibility is contribution to chi-square, but I generally prefer standardized Pearson residuals. – Glen_b Sep 12 '14 at 1:48
• heatmaps will be good. – kjetil b halvorsen Dec 7 '15 at 16:00