# AW: st: AW: Graph: Colouring table cells based on conditions or data distribution

 From "Martin Weiss" To Subject AW: st: AW: Graph: Colouring table cells based on conditions or data distribution Date Fri, 16 Oct 2009 12:00:15 +0200

```<>

" in the talk Martin referred to."

I would love to take credit for the reference, but... (avid statalisters can complete this sentence themselves...)

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Nick Cox
Gesendet: Freitag, 16. Oktober 2009 11:59
An: statalist@hsphsun2.harvard.edu
Betreff: RE: st: AW: Graph: Colouring table cells based on conditions or data distribution

Colour-coding cells, however, covers at least two kinds of idea:

1. Qualitative coding: Look! This cell contains a very high value, or a very low value, or a negative value, or whatever. Used sparingly, this can be useful and effective.

2. Quantitative coding: Look! In addition to showing you the values, I am also using a series of colour shades. (The example given on the Microsoft web page Stefan referred to shows a scale running from green through yellow to orange, which in my view just complicates the table!)

An alternative to quantitative coding is just to show e.g. bars and numbers, i.e. to hybridise tables and plots. For want of a standard name, I call these table plots. There are programs to do this on SSC, -tabplot- and -tableplot-, and examples in the talk Martin referred to. (The most recent version of this talk was given at the Washington, DC meeting a few months ago.)

Nick
n.j.cox@durham.ac.uk

Nick Cox

In essence, as Maarten's reference implies, it can be done. I don't have a precise recipe for your particular request, but the code in -corrtable- from SSC shows one strategy:

loop over cells in table {
draw a graph for each cell with desired text and colour
}

combine the graphs

Another strategy would resemble ways in which people draw heat maps, or indeed maps, by a series of calls to -twoway area-. Sergiy Radyakin has done something similar to that, but I can't vouch for whether he has code to do what you want that is also publicly available.

Maarten buis

This talk by Nick Cox at the last German Stata Users' Meeting may be
what you are looking for.

http://ideas.repec.org/p/boc/dsug09/01.html

--- On Fri, 16/10/09, Stefan.Gawrich@hlpug.hessen.de wrote:
> In my work I often have to display both a table (to pick
> data from) and a graph (for visual impression) to users
> and I'm constantly trying to combine both. Colouring
> tables is one way to do this if rules/conditions are
> user-defineable.
>
> I thought about setting up a coloured twoway table in Stata
> but that doesn't seem to be easy

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```