Friday, 30 August 2013

Colour schemes for maps and charts

A few useful resources:
  • Colorbrewer: hand-picked colour schemes by Cynthia Brewer, designed for maps but also useful for other visualisations. All of the palettes are available in the RColorBrewer package for R. This is a useful introductory paper on data maps by Cyntia Brewer.
  • Escaping RGBland is a paper by Zeileis, Hornik and Murrell describing principles for creating your own Colorbrewer-like schemes. Section 6 describes the colorspace package in R, which makes it easy to put the paper's principles into practice.
  • The Cookbook for R includes a couple of nice simple colourblind-friendly palettes, based on this page on Color Universal Design.
  • I Want Hue is a good tool for creating categorical palettes.
  • Here is a much more comprehensive list of resources from Visualising Data.

Monday, 26 August 2013

Sparklines for time series economic data

Sparklines make it possible to fit a huge number of data points in a small space. I recommend Edward Tufte's chapter from Beautiful Evidence (image, left) and Stephen Few's article on scaling sparklines.

While planning my dashboard page, I came across a number of sites that use sparklines for economic indicators, including the home page of FRED. FRED is a fantastic economic data site that makes it very easy to find data on the US economy and beyond. These sparklines fit quite a bit of data in a small space, and a more detailed chart appears on hovering the mouse. I think that the charts could be improved, however, by a bit more information about scaling. Each chart shows approximately ten data points, and it would be useful to add 'last 10 months' or 'last 10 quarters' etc below each chart. Two numbers could also be added to the left of each chart to show the minimum and maximum values. Finally, the vertical scale could be expanded slightly to fill the space available.

Friday, 23 August 2013

Mapping deprivation

These are some of maps I took inspiration from for the design of my map of deprivation in London. I'm not an expert cartographer, so the end result of my map is not as good as these in many respects.

Alastair Rae's maps (including this one of Scotland) inspired me to try using Fusion Tables for choropleth mapping in the first place. Rae is an expert on maps, and his designs and colour schemes are very clear. One of my favourite features of the Scotland map is the full-screen mode.

The Scottish Government's SIMD map has several useful features, including a transparency slider, several options for colour banding, and comparison of areas.

The Data Visualisation Team at the Office for National Statistics have dozens of well-designed visualisations on their Interactive Content page. The Atlas of Deprivation is entirely SVG-based rather than using a detailed map background. The result is a map that responds very quickly to user interaction. The map has several great features including the option to show a local rather than national comparison. The image here shows ONS's legend design. I based my legend on this. Incidentally, I liked this interview with Alan Smith from the ONS team.

I borrowed a number of ideas for features and page design from the Open Data Communities map of England.

Visualisations from the New York Times are consistently excellent. One thing I've picked up from the NYT's maps is that the background to a semi-transparent choropleth map should be white to avoid misleading colour blends. See this map of Netflix queues for an example.

Another New York Times map has place names above the data. This got me thinking about how to make the base map and text as legible as possible. First, I added some transparency options so that the user can choose between brighter colours and a more legible basemap. Secondly, I brightened up the colours (which I got from Colorbrewer) slightly so that they would appear bright even after being made slightly transparent. It didn't make as much difference to the end result as I had hoped, but I can provide the details if anyone would find it helpful.

I really like this map by Oliver O'Brien, which only colour-codes the area occupied by housing, but I'm not skilled enough to do anything similar!

Monday, 19 August 2013

UK economic dashboard

The Office for National Statistics publishes thousands of long-run economic data series in machine-readable CSV and XML formats. Although the download facility on the ONS website is incredibly useful, it can sometimes take a bit of effort to find the latest data for a given variable, and the site does not yet have a quick way to visualise the data.

With these things in mind, I created the UK Data Explorer dashboard page to provide a quick way to view economic indicators. The page includes ONS's list of over 50 key time series indicators, and it is also possible to search for a variable by name or code from a much wider list. The page provides a link to your customised dashboard, to make it easy to return at a later date and check the progress of indicators. For example, this dashboard shows seven headline indicators on the labour market, GDP and inflation.

The page is still in beta, and there are several features I hope to add in the near future, including the ability to show multiple variables on the same graph and more descriptive variable names and metadata. Please let me know if there are any features that you would find useful.

Some technical details
The site uses a script to check for updates on the ONS website a few minutes after the 9.30 publication each day. The script downloads the CSV file of each new dataset, and places the data and metadata in database tables. The dashboard page uses HTTP requests to PHP scripts to access the data in these tables.

Thursday, 15 August 2013

Uploading UK boundary maps to Google Fusion Tables

Here goes my first attempt at blogging! I thought I'd jot down a few notes on importing UK maps to Google Fusion Tables. There's loads of information online on creating maps (for example here), so I won't cover the basics of Fusion Tables.

A good place to start looking for boundaries is this blog post from Simon Rogers, which has several ready-made maps. If you don't find what you need there, try ONS's Open Geography Portal. The 'Download Boundaries' section is one option, but I find it's handier to use the 'Browse' section, then Digital Boundaries. Within this section, choose a geography type from the left panel, and select Details in the right panel. (Generalised files are smaller but less detailed than Full files. Clipped files are clipped to the coastline.)

Finally, scroll to the zip download, which is among the Transfer Options links.

You can then upload the shapefile to Fusion Tables using Shape Escape. As an alternative, I've found the rgdal package in R to be useful. This is an example script to create a KML file for uploading to Fusion Tables:

shapeFileName <- 'LAD_DEC_2010_GB_BGC.shp'
layerName <- ogrListLayers(shapeFileName)
shp <- readOGR(dsn=shapeFileName, layer=layerName)
shpWGS84 <- spTransform(shp,CRS("+proj=longlat +datum=WGS84"))
writeOGR(shpWGS84, "LA.kml", layer="LA",driver="KML")

You can also join data to the geographical boundaries in R, using the shp@data data frame. I don't have much experience of doing this, but I'd recommend trying the  join function from the plyr package.

For map colours, I'd recommend

This is my first attempt at using D3 and Fusion Tables together for a map. I might cover some more details of this in another blog post, or feel free to ask!