Making a pie chart map and its legend, QGIS 1.8

, , Leave a comment

Collecting data was a long process and when I realised I had collected enough for my research, I thought long wasted days were gone… Not that collecting data was wasting my time, but that it was made of a lot of waiting time –in rainy, sunny, or windy weather– that seemed to stretch the days in weeks and a lot of organisation reducing the weeks in days. Then I started putting together my results; trying to make sense of them, and to present them in an easy way to understand. That’s when I experienced the long days where I could barely manage to make a map.

I’m a mac user, and so no ArcGIS for me; unless I use the computers of the uni. On the other hand, Quantum GIS (QGIS) is improving every day (literally!), and it’s a real pleasure to digitize with it –although ArcGIS10 made some efforts, but more on that later I hope. I had never tried to make maps with pie charts, as they are difficult to read and therefore never my first choice. However, they seemed the most adapted when I decided to make a map to represent the frequency and all the activities carried out in the parks in Portsmouth. Actually, representing all the different activities in the parks is the data that requires the pie chart.

I’ll explain here first how I organised my data, then how I used QGIS to make the map, and then the legend.

Data Preparation

After my surveys I had a spreadsheet like that, where ID are the people I surveyed:

ID        NamePark    Activity

A         Park1            Bird watching

A         Park5            Walking

B         Park1            Walking

B         Park3            Walking

B         Park10          Dog walking

C         Park3            Recreation

D         Park10          Dog walking

I used the Pivot Table in Excel to obtain something like this:

NamePark    Bird watching     Recreation      Dog walking    Walking

Park1            1                        0                        0                      1

Park3            0                        1                        0                      1

Park5            0                        0                        0                      1

Park10          0                        2                        0                      0

Pie Charts Map

Then, making a map with pie charts (or diagram) in QGIS is really simple.

Double click on your layer (or right click, properties),

go to the tab ‘Diagrams’,

tick the box ‘Display diagram’,

choose ‘pie chart’

the options can be decided after (especially the size, placement can be chosen depending on your data)

choose the attributes you want (I chose the four activities), add them with the ‘+’ button on the right

and finally click ‘OK’

In the options, I’ve chosen ‘Fixed size’ and placement ‘Around Point’, which could actually fit quite well my data but give me something like that (default colours):


fig1: Extract 1 of the park frequency/activity map

Parks non-used by the participants in my survey are in grey, the colors indicate how well they are used and the pies the activities. The result is quite good, but because some of the parks are quite small, and I didn’t want too much overlapping I wanted to be able to move the pies to avoid what happens in the two parks in the north of this extract. And I wanted also to make a nice legend (which ArcGIS doesn’t seem to be able to do either). There is an option ‘free’ for the placement that I still don’t understand how to use, but I went around it with a little trick… and obtained the following map:


fig2: Extract 2 of the park frequency/activity map

With this placement there is no guessing which pie applies to which park. The pies are, as much as possible next to the park but far from the other parks. To make this map, I created a new layer of points and made the pies on the points, which I could move very easily and make a legend out of it. To make it quickly, I created the centroids of the polygons:

Vector > Geometry tools > Polygon centroids

This kept all the activities information, which was then easy to create exactly the same pie charts. Then I enabled editing on the layer to move the points-pies where I wanted them to be. Maybe that’s what the ‘free’ option does, but at least these points helped me create the legend.


I made two different legends, and I’m still not sure which one I prefer. The first one required to add a dummy point with 1 in each activity and to put it in an empty part of the map. Then in the print composer I entered manually some text next to it to obtain that:

fig3: legend1

It’s a bit awkward though as it’s not in the legend part of my map.

So, as an alternative, I decided to use the points to make a legend. I used one of the fields to make up four (virtual) categories, and renamed the layer as ‘Activities (pies)’ in the brand new legend tool. The latest QGIS version (1.8) has improved so much the legend! They were coming from far, though, but now it’s possible to make proper maps with it, so it’s perfect.

fig4: Legend2

I still don’t know whichever I prefer. But I’m really happy I managed to have the option to make nice pies and useful legend!

Using the pie chart on the map allow presenting more detailed information, which I found very useful. It would be as well possible to use the size of the pies to give an idea of the number of people who said they used the park (there is an option dedicated to that in QGIS). However I find this even less easy to read than the portions of pies. Still looking for a way to represent that on the same map!

QGIS 1.8 is very promising, although I doubt I’ll see QGIS 2.0 before the end of my PhD. Or at least, I hope.


Leave a Reply