[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From   Austin Nichols <>
Subject   Re: st: AW: Graph: Colouring table cells based on conditions or data distribution
Date   Fri, 16 Oct 2009 13:13:59 -0400

Nick Cox <> :
So maybe you pick a yellow-purple gradation instead--the color palette
choice I was assuming was a user choice...

sysuse nlsw88, clear
g g=max(grade,8)
la var g "Years of education"
ren married m
collapse wage, by(g m)
g w=round(wage,.01)
su wage, meanonly
g c=round((wage-r(min))/(r(max)-r(min))*255)
qui levelsof c, loc(cs)
loc g
foreach c of loc cs {
 loc c1=120+round(`c'/2)
 loc c2=255-round(`c'/2)
 loc m mc("`c2' `c2' `c1'")
 loc g `g'||sc m g if c==`c', ms(S) msize(ehuge) `m'
loc g `g'||sc m g, ms(i) mlab(w) mlabp(0)
loc g `g' leg(off) yla(-.75 " " 0 "N" 1 "Y" 1.75 " ", notick)
loc g `g' xla(7 " " 8/18 19 " ", notick)
tw `g'  scheme(s1mono) ti(Wage heat map) xsize(8) ysize(5)

On Fri, Oct 16, 2009 at 12:12 PM, Nick Cox <> wrote:
> Another red-green gradation!
> In two books that have crossed my desk recently, (subdued) orange and
> blue are used for basic contrasts of two categories to good effect.
> Few, Stephen. 2009. Now you see it: Simple visualization techniques for
> quantitative analysis. Oakland, CA: Analytics Pres.
> Hastie, Trevor, Tibshirani, Robert, Friedman, Jerome. 2009.
> The elements of statistical learning: Data mining, inference, and
> prediction. New York: Springer.
> Nick
> Sergiy Radyakin
> have a look at this page:
> htm
> If this is something that you are looking for, contact me to get the
> program files.
> On Fri, Oct 16, 2009 at 3:33 AM,  <>
> wrote:
>> many of you may know this feature from MS Excel (from Version 2007
> on).
>> It's more or less a "choropleth map" for data tables (cell colour
>> depends on cell value relative to the table distribution or on
>> conditions).
>> (see:
>> 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:
>> Stata's results window doesn't allow for fancy tricks so the table
> must
>> be in a graph.
>> Spmap by Maurizio Pisati has all colouring options I need and can be
> set
>> up with rectangular polygons and polygon centroids for labeling.
>> But it's not written for that purpose, so it's difficult to set up:
>> - a n*m polygon-coordinates dataset for each table must be created
>> - linkage of table cells to polygons
>> - handling of missing values and category "missing"
>> - use of value labels
>> - display of row and/or column totals (yes/no)
>> - ...
>> I already started to produce some coloured tables with spmap but these
>> are only first tests.
>> I'm curious if there is any other graph framework available in Stata
>> which also may be suitable for this purpose.

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index