Using Grid Graphics to produce enable one layout template to plot - - PowerPoint PPT Presentation

using grid graphics to produce
SMART_READER_LITE
LIVE PREVIEW

Using Grid Graphics to produce enable one layout template to plot - - PowerPoint PPT Presentation

Agenda Linked micromaps (LM plots) what they are background from statistical graphics Use of Grid Graphics Using Grid Graphics to produce enable one layout template to plot many maps linked micromap plots of large multiple


slide-1
SLIDE 1

Using Grid Graphics to produce linked micromap plots of large financial datasets

Gordon Blunt, CACI Ltd gblunt@caci.co.uk useR! 2006, Vienna

Agenda

Linked micromaps (LM plots)

– what they are – background from statistical graphics

Use of Grid Graphics

– enable one layout template to plot many maps – multiple coordinate systems cope easily with different data sets – Grid Graphics’ grid.layout()

  • more flexible than traditional graphics’ par(), split.screen() or

layout()

Conclusions & further work

N.B. This talk is not an overview of Grid Graphics

– much better done by Paul Murrell

R Graphics (2005), Chapman & Hall

Linked micromaps Method for plotting statistical data

– while maintaining the spatial context

Presented by Carr et al. (1998)

– following earlier work in related areas – Carr and Pierson (1996)

  • others shown in references

Dan Carr, George Mason University

– seems to have been involved in most published LM plotting work – used to display data sets from

  • official statistics
  • epidemiology
  • ecology

Linked micromaps Elements from

– Cleveland (1985, 1993)

  • dot plots

– can easily extend to other types of statistical graphic

  • ordering
  • good statistical graphics and layout

– especially common scales, position

– Tufte (1990, 1997, 2001)

  • small multiples

– Kosslyn (1994)

  • psychology of graphical perception

– colour – number of elements – linking these unambiguously

slide-2
SLIDE 2

Mean new mortgage value and proportion of mortgages at 95%+ loan-to-value ratio

Leicester LE 4 5 Leicester LE 2 0 Leicester LE 4 6 Leicester LE 3 5 Leicester LE 5 3 Leicester LE 5 4 Barwell Leicester LE 1 3 Leicester LE 3 2 Leicester LE 3 0 Oadby Loughborough Leicester LE 3 1 Leicester LE 5 0 Anstey Leicester LE 4 2 Leicester LE 4 9 Leicester LE 4 7 Stoney Stanton Melton Mowbray Leicester LE 1 4 Ibstock Leicester LE 3 9 Blaby Leicester LE 1 2 Wigston Leicester LE 5 5 Leicester LE 2 6 Wigston Birstall Birstall Melton Mowbray Birstall Syston Glenfield Coalville Humberstone Leicester LE 4 0 Loughborough Croft Coalville Shepshed Hinckley East Goscote Coalville Blaby Leicester LE 3 6 Oadby Loughborough Leicester LE 2 8 Enderby Fleckney Mountsorrel Enderby Cosby Oadby Humberstone Syston Coalville Hinckley Leicester LE 2 1 Leicester LE 1 7 Thurcaston Loughborough Barrow upon Soar Leicester LE 1 5 Costock Earl Shilton Leicester LE 1 6 Markfield Evington Leicester Forest East Groby Oadby Leicester LE 2 3 Ratby Market Harborough Kibworth Harcourt Enderby Leicester LE 1 1 Saxelbye Ellistown Market Harborough Leicester LE 2 7 Desford Normanton

  • n Soar

Swannington Kibworth Beauchamp Hinckley Ashby Parva Blaby Loughborough Cosby Enderby Countesthorpe Stoke Albany Houghton

  • n the Hill

Barrow East Goscote Goadby Marwood Ashby-de la-Zouch Oakham Hinckley Ashby-de la-Zouch Lutterworth Leicester LE 2 2 Lyndon Little Dalby Uppingham North Kilworth 80 100 120 140 160 180

Mean new mortgage, £000s

80 100 120 140 160 180

Mean new mortgage, £000s

10 20 30

  • Prop. 95%+ LTV, %

10 20 30

  • Prop. 95%+ LTV, %

1st Quartile 2nd Quartile 3rd Quartile 4th Quartile

Top right part of plot

Leicester Lyndon Little Dalby Uppingham North Kilworth

80 100 120 140 160 180 Mean new mortgage, £000s 10 20 30

  • Prop. 95%+ LTV, %

Key features of linked micromaps

Data sorted

– but the map caricatures don’t show data

Each column of plots to same scale Simplified boundaries

– Dirichlet tesselation for internal boundaries – simplify external boundaries too

Legend Small multiples Colour Distort the map if necessary

– it spatially indexes the data, it is not accurate geography – e.g. for UK, we typically squash it north – south, move some of the islands nearer the mainland

!" Chart titles Quartile labels Quartile labels Axis text, labels Footnote The number of blue rows varies depending on the number of areas; grid.layout() fills the viewport with equally sized plotting areas

grid.layout(), viewports and Grid’s coordinate systems essential

2.5lines 2null Name width 2.5null 2.5null 2mm 2null Name width 2.5null 2.5lines 2.5null 1lines 1lines 1null 1null 1null 1null 1null 1null 1null 1null 1null 1null 1lines 1lines 1null 1null 1null 1null 1null 1null 1null 1null 1null 1null 2lines 2lines 1lines 2null Name width 2.5null 2.5null 2mm 2null Name width 2.5null 2.5null 1lines (1, 1) (1, 2) (1, 3) (1, 4) (1, 6) (1, 7) (1, 8) (1, 9) (2, 1) (2, 2) (2, 3) (2, 4) (2, 6) (2, 7) (2, 8) (2, 9) (3, 1) (3, 2) (3, 3) (3, 4) (3, 6) (3, 7) (3, 8) (3, 9) (4, 1) (4, 2) (4, 3) (4, 4) (4, 6) (4, 7) (4, 8) (4, 9) (5, 1) (5, 2) (5, 3) (5, 4) (5, 6) (5, 7) (5, 8) (5, 9) (6, 1) (6, 2) (6, 3) (6, 4) (6, 6) (6, 7) (6, 8) (6, 9) (7, 1) (7, 2) (7, 3) (7, 4) (7, 6) (7, 7) (7, 8) (7, 9) (8, 1) (8, 2) (8, 3) (8, 4) (8, 6) (8, 7) (8, 8) (8, 9) (9, 1) (9, 2) (9, 3) (9, 4) (9, 6) (9, 7) (9, 8) (9, 9) (10, 1) (10, 2) (10, 3) (10, 4) (10, 6) (10, 7) (10, 8) (10, 9) (11, 1) (11, 2) (11, 3) (11, 4) (11, 6) (11, 7) (11, 8) (11, 9) (12, 1) (12, 2) (12, 3) (12, 4) (12, 6) (12, 7) (12, 8) (12, 9) (13, 1) (13, 2) (13, 3) (13, 4) (13, 6) (13, 7) (13, 8) (13, 9) (14, 1) (14, 2) (14, 3) (14, 4) (14, 6) (14, 7) (14, 8) (14, 9) (15, 1) (15, 2) (15, 3) (15, 4) (15, 6) (15, 7) (15, 8) (15, 9)

slide-3
SLIDE 3

Coordinate systems

Many coordinate systems are available in Grid We used the following to produce LM plots

native (locations relative to x and y scales of the current viewport) npc (normalised parent coordinates) strwidth (string width – for the area names in columns 2 and 7) lines (locations specified relative to current font size) mm (millimetres) char (locations specified relative to multiples of current font size)

Also, and specific to grid layouts

null (allows plot elements to be equally sized – by Grid – to fit around the areas where the size needs to be fixed)

There are other coordinate systems too!

Other Grid features

Not essential, but useful in our implementation

A plot drawn in a Grid viewport fills the viewport

  • the axes are outside the viewport by default
  • unless we use plotViewport()

– sets up a central plotting region within a viewport

  • LM plots require only one set of axes at the bottom of each column
  • f plots

We’ve found it easier to explain LM plots to clients if each plot is separated – slightly – from every other element

  • have used the width and height arguments to shrink each plot

element by a consistent amount

  • in conjunction with npc and native coordinates Grid graphics does

this regardless of x and y limits

Can place text precisely in viewports

  • or across viewports, if the clip argument is off

Conclusions

LM plots add insight to our discussions with our clients We have adapted Carr et al.’s (1998) methods for displaying financial datasets; the following are crucial

– variables are shown by distance along a linear scale – they are measured from a common axis – the data need to be sorted – number of points in each plot element needs to be relatively small – the plot elements are arranged in small multiples – white gridlines should be used to add guides but not clutter

If the quartile shadings indicate little, or no, spatial pattern:

– we might conclude that LM plots are unnecessary – so the data could probably be better represented by a simpler method

Further work Different types of statistical graphic

have also used (slightly modified) box percentile plots

see Frank Harrell’s bpplot(), based on Esty and Banfield (2003) used by Dan Carr too …

who has also used

time series rates of change

however, the dot chart seems ideal for LM plots

easily understood by my (mostly) non-statistical clients

Our functions work for up to 144 areas

is it possible to plot more?

I suspect not on A3 paper this shouldn’t be a limitation