Visualization Idea for Elections (Jitter coordinates in Tableau)

Fatih Boyar
4 min readJan 20, 2023

--

We have gotten used to seeing the election results on a map, cities painted with the winning party’s color. It is easy to see which party got the majority of votes in a particular city, but this practice misleads us as if the area has any indication of the values. Here is a typical example of visualization from Wikipedia; Turkish parliamentary election, 2018:

https://tr.wikipedia.org/wiki/2018_T%C3%BCrkiye_genel_se%C3%A7imleri

This is quite common, and I do not remember any other certain way of visualization on TV on election day. This visualization involuntarily indicates the area is relevant to the votes. Because our minds are wired with biases and it is almost instant that we infer a pattern from what we see. Even though AKP’s votes were close to 50% values are exaggerated on the map. Some cities have greater areas but less population and others are vice versa. What is worse is that Istanbul has 3 times more people than 2nd biggest city, Ankara. And in the end, the total number of votes matter. Therefore, I am suggesting a better way to visualize the votes on a map in which all the parties can be shown in every city.

Here are the 3 biggest parties’ votes in the election. Colors indicate the part and circle sizes indicate the total number of votes. At first look, it is obvious that the 2nd and 3rd parties (CHP, HDP) are greatly underrepresented on the typical map. In contrast, some of the big cities with the majority of CHP votes have underrepresented also for the AKP votes. Furthermore, this way of visualization is more informative, regarding the total votes in a city. Note the huge crowding near Istanbul and tiny circles in the eastern regions.

We can zoom in on an area and get more details. For example, let's see Istanbul. We can hover the cursor on the circles and get more info. Even though AKP is the majority in Istanbul, the opposition is hard to ignore.

Another detail is informative about the 2nd major party in the southeast region. Note how red circles are shown as tiny.

In conclusion, we should be aware of our biases and shortcuts hardwired in our minds. Quoting directly Daniel Kahneman in Thinking, Fast and Slow; “What you see is all there is”. The typical mapping of votes is not only short-coming but misleading also.

Now for who curious about the technical side, here is how I made this visualization. Firstly, I added the coordinates of the cities to the table from the Wikipedia page manually (Thanks to https://gist.github.com/ismailbaskin/2492196). Then changed the table on from wide to long format using pandas.melt function. With this way, I acquired City, Party, Votes, Latitute and Longtitude variables and these are all I needed. If same coordinates are used then circles would be on top of each other. To prevent this, I created calculated fields for latitude and longitude, assigned jittered coordinates for each parties.

Only a bit trigonometry is involved here. Jittered coordinates are in detail, far from the actual coordinates with a certain angle and parameterized distance. Sinus function is used for latitude and cosinus function is used for longitude. I was able to do exactly what I was hoping for thanks to this excellent post from tableu community: https://community.tableau.com/s/news/a0A4T000001v7TOUAY/jitter-those-points

Here is the link for my Tableau visualization if you are curious about the details: https://public.tableau.com/views/Turkey_poll_2018/Votes3BiggestPartiesonMap?:language=en-GB&publish=yes&:display_count=n&:origin=viz_share_link

--

--

Fatih Boyar
Fatih Boyar

Written by Fatih Boyar

Wondering around probability, data science and philosophy. Aim is to be less wrong. Rationally Curious.

No responses yet