Select Page

Visualising UK Petitions

It started with a tweet…

Philip’s a friend I originally met by way of parenting, but as it happens is also a Professor of Politics.  He tweets prolifically but this sequence caught my eye – there’d been some buzz regarding the disproportionate rate at which different parts of the country were signing that Donald Trump petition (1.85m signatures and counting at the time of writing)

Knowing that mapping was an area I wanted to do more with in Tableau I thought that this would represent an interesting challenge, though obviously someone would already have done a far better job before I’d even got my head around the concept of subpolygons.

Nevertheless, that evening I had a go, to see whether I could create something. I found that the petitions website allowed one to download a file (or “get petition data (json format)” as they put it), so that seemed a pretty good start.  But what’s a JSON file really?  I’d seen references to the format before, but never actually done anything with one.

What a fantastic coincidence, then, to find that Tableau had incorporated a specific JSON file connector in version 10.1 – too good to be true, huh?  No, what’s too good to be true is just how intuitive the import functionality built into Tableau is:

So, suddenly I have a list of parliamentary constituencies and the number of times the people living in them signed a petition, all ready to go in Tableau.  Can I map them?  Not straight off – Tableau doesn’t (yet) support UK geography at constituency level.   However, there are some ridiculously resourceful people out there, sharing some fantastically useful resources, and tableaumapping.bi is a prime example.  Ready and waiting was a .tde file with 632 constituencies already mapped (as yet, the 18 from NI aren’t included). Fantastic!  But, of course, there’s the next hurdle (a.k.a. feature to learn) – how to actually use it! First stop, the Tableau video tutorials, and this absolute beauty – five minutes and it’s cracked.  I’ve already lost count of how often I’ve needed to quickly get my head around a feature and the video tutorial has nailed it first time, often better and always quicker than trying to navigate the messageboards.

So, I have a data set and a map.  But wouldn’t two datasets be more fun?  Could I actually answer Philip’s question here?  I’d made a wild assumption that the phrase “other petitions” was a gentle hint at the EU referendum petition (4.15m signatures), so I sought out the file on that one too.  I constructed a comparison tool to identify those constituencies which appeared to lean more towards signing one rather than the other.  Not on a pure numbers basis, of course, but relatively.  This xkcd comic should loom large in anyone’s mind when trying to pull together maps to visualise data:

Of course, in this case we do have a headstart – UK constituencies are generally of a similar population size, but have vastly different area sizes.  Of course, with numbers as big as four million, even the least anti-Brexit constituencies had still signed that petition more than even the most anti-Trump constituencies had this.  So what I wanted to do was think of their relative contributions towards each petition.  I’ve written a whole other, more detailed post on my methodology – go read that after this one. 😉

So, here was the first cut, slapped on to Tableau Public that same evening.  Two vizzes: a map and a scatter plot.

<center><div class='tableauPlaceholder' id='viz1486981744619' style='position: relative'><noscript><a href='#'><img alt='UK Petition Map ' src='http://public.tableau.com/static/images/UK/UKPetitionComparisonTool/UKPetitionMap/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='http%3A%2F%2Fpublic.tableau.com%2F' /> <param name='site_root' value='' /><param name='name' value='UKPetitionComparisonTool/UKPetitionMap' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='http://public.tableau.com/static/images/UK/UKPetitionComparisonTool/UKPetitionMap/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1486981744619'); var vizElement = divElement.getElementsByTagName('object')[0]; vizElement.style.width='544px';vizElement.style.height='969px'; var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script></center>
<center><div class='tableauPlaceholder' id='viz1486982070532' style='position: relative'><noscript><a href='#'><img alt='Petition Scatter ' src='http://public.tableau.com/static/images/UK/UKPetitionComparisonScatterPlot/PetitionScatter/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='http%3A%2F%2Fpublic.tableau.com%2F' /> <param name='site_root' value='' /><param name='name' value='UKPetitionComparisonScatterPlot/PetitionScatter' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='http://public.tableau.com/static/images/UK/UKPetitionComparisonScatterPlot/PetitionScatter/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1486982070532'); var vizElement = divElement.getElementsByTagName('object')[0]; vizElement.style.width='504px';vizElement.style.height='569px'; var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script></center>

Possibly interesting, if somewhat flawed.  We’re looking at the two most popular petitions possibly in British history and an r-squared value of 0.86.  What can we meaningfully draw from this?  Arguably not so much without better context.  But now I was intrigued at the possibilities, and kicked off an email exchange with the Professor to see how far off the mark I was.  He returned with a shopping list, but the killer item was this one:

Here’s what I’d like to see (if it’s do-able…). Take ALL petitions signed so far (or this year, or whatever, but a decent number). Sum the number of signatories. And see which places sign more petitions *in general*.

A series of iterations followed.  I downloaded all the petitions that had crossed the 100,000 signatures threshold (I hate round numbers, but this number is at least of significance in the world of petitions), totaling 42 closed and 12 that were still open.  I figured that those 42 would provide us with a benchmark rate at which constituencies signed petitions historically, which we could then use to set our expectation.  So, if Sheffield Central had historically contributed 0.32% of all signatures to petitions in the past, it would be reasonable to assume that, political factors aside, the same would apply to another petition in the future.  So, were the people of Sheffield Central signing 0.32% of the anti-Trump petition?  And if the actual number was different, how much different?

So then, the method was born.  As I mention, I’ve detailed the approach I took in a separate post.  For something this complicated the transparency is pretty vital, and I borrowed a few statistically-minded colleagues to cross-check my sums.  So far, so good.  But something was nagging me – we’re only looking at the big petitions.  Could they, by their very nature, be skewing the picture somewhat?  I caught up with Philip again and he had a few bright ideas, including enlisting the support of Chris Hanretty, also a politics academic, who was kindly able to pull together the petition data from all the closed petitions, irrespective of size.

So, now I’m sitting on a dataset of approaching 7,000 petitions, and the skills to map them.  So let’s do just that – here are the maps, one each for Wales, England and Scotland, showing the relative density of signatures in each constituency:

So, what we are able to show is that some regions of the UK are predisposed to sign petitions more than others, and here we’ve created our benchmark.  Going back to Philip’s email, the next item on his list was:

Then, compare the ranking of places on that list with the ranking of them on Trump.

Well, the ranking no. We would lose the sense of scale if we simply recorded that the people of Bristol West had signed the anti-Trump petition more than any other constituency.  The question should be how much more are they signing it than other constituencies and, moreover, is this in line with what we would expect anyway?

Let’s get down to specifics.  By the method, we’d have expected Bristol West constituents to have signed the petition 8,355 times.  In fact, at the time the data was taken, they’d signed it 13,128 times, almost exactly one for every ten constituents, and 57% more than we’d have otherwise expected.  However, in terms of outstripping expectation, they actually only rank 38th – many constituencies almost doubled their expected contribution, chiefly those in Scotland.

At the other end of the spectrum, meanwhile, the people of Basildon, Boston and Doncaster were signing the petition less than half as many times as we’d come to expect.  So, we’re able to identify some variability here, which will no doubt be attributable to a range of factors, primarily all sorts of demographic elements.  I’ll leave others to speculate on what those factors might be.

This exercise is then repeatable – adding a filter to the dashboard allows the interactor to switch between the biggest open petitions.  So here’s the finished* viz – an interactive scatterplot of responses to a single petition compared with historic petitions.

<div class='tableauPlaceholder' id='viz1487368297097' style='position: relative'><noscript><a href='#'><img alt='Scatter Dash ' src='http://public.tableau.com/static/images/Pe/PetitionsByConstituencyFinalUpload_0/ScatterDash/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='site_root' value='' /><param name='name' value='PetitionsByConstituencyFinalUpload_0/ScatterDash' /><param name='tabs' value='no' /><param name='toolbar' value='yes' /><param name='static_image' value='http://public.tableau.com/static/images/Pe/PetitionsByConstituencyFinalUpload_0/ScatterDash/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1487368297097'); var vizElement = divElement.getElementsByTagName('object')[0]; if ( divElement.offsetWidth > 800 ) { vizElement.style.width='904px';vizElement.style.height='769px';} else if ( divElement.offsetWidth > 500 ) { vizElement.style.width='100%';vizElement.style.height='869px';} else { vizElement.style.width='100%';vizElement.style.height='769px';} var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script>

* Already I have a growing list of enhancements for a subsequent iteration.  As Philip rightly points out, owing to the respective political systems in Scotland and Wales, these should be taken independently rather than analysed with England too.  So we should run three analyses, one for each country.  I’d also love to incorporate the mapping for Northern Ireland, which would require amending the existing .tde file.  And, finally, to look at historical petitions alone and compare regional contributions with other demographics – the House of Commons’ own Tableau Public page contains all sorts that should provide a decent starting point.

About The Author

Mark Edwards

A statistician at heart, Mark’s approach is always numbers-led. Already visualising data in other side-projects, Mark was introduced to the world of Tableau in 2016, when he and Pablo started working together in UK financial services. A keen participant in social Tableau challenges, Mark is building his skills and appreciation of clean and simple visuals, discovering interesting and untapped data sets, a path that has already led to a new career and a range of further opportunities. Mark is a Tableau Desktop Certified Professional, a Tableau Social Ambassador and an annual attendee of the Tableau Conference in the US.

Trackbacks/Pingbacks

  1. Merging Two Polygon Maps In Tableau | POINTS OF VIZ - […] Visualising UK Petitions 25 Years of Aircraft Wildlife Strikes in USA Has Apple lost their grip with iPhone sales?…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.