Site menu:


Site search

QGIS Diagrams – Pie Charts for Symbols!

QGIS has a great feature that allows you to create pie charts for feature symbols! I have known about it for a while, but never really had the opportunity or reason to play with it. However, this post on prompted me to take a look. Here’s a quick summary of how the ‘Diagrams’ functionality works in case you’re like me and haven’t had time to check it out! It’s easy to do, and works pretty well!

As an example, I created a random sample dataset with some fictitious data. It contained three points, and the attribute table looked like this:

Attribute Table

Attribute Table

To create a diagram symbol, go to the properties for the layer in question, and click the “Diagrams” tab at the top, then check off “Display Diagrams” and set Diagram type to “Pie Chart.” You can also use “Text Diagram” but that’s another post!

You can set either a fixed size, or scale the size of the charts to an attribute value range. This is useful if you are wanting to use the size of the symbol to indicate a value, and the ‘slices’ to indicate percentages. In my case, I set the size to ’23’ and set it to scale between 0 and 30mm. This is arbitrary in my case, but you can play with it using your own data to see what works best for you.

At the bottom under “Attributes,” select each attribute you want to form a ‘slice’ of the pie, and click the ‘+’ on the right. Then select the next value, and click ‘+.’  Repeat until you are finished adding all values. In my case, I added attributes A, B, C, and D. I didn’t want to use the ID, so I left it out. You can set individual colours for each ‘slice’ here by double clicking the colour in the table. Here’s what my settings looked like:

Pie Chart Settings

Pie Chart Settings

and here’s here what the final product looks like:

Final Result

Final Result

This is already a great tool, and with a few more enhancements, it will be a fantastic tool! What enhancements you wonder? A couple that immediately come to mind are the ability to label ‘slices’ with either their attribute value, or their percentage, and the ability to remove all borders (in the above example, ‘Pen Width’ is set to 0, but it still shows a border. Weird.)

What features would you like to see?


Comment from Anna
Time November 3, 2011 at 6:38 am

My question is how to display legend of the diagram symbols in composer?

Comment from darrencope
Time November 3, 2011 at 6:45 am

Good catch Anna! I don’t currently see a way to do that. Its certainly one for the wish list! I guess you’ll have to screenshot an example and insert it as an image in over top of the legend for the time being….unless someone knows a better way?

Pingback from DARREN COPE » 2011 – The Year in Review
Time February 21, 2012 at 9:45 pm

[…] QGIS Diagrams – Pie Charts for Symbols! […]

Comment from mike
Time February 28, 2012 at 7:25 am

what about when you have lots of pies so some would be on top of each other, only some of them display and its not clear which ones its going to display

Comment from darrencope
Time February 29, 2012 at 6:01 pm

Hi Mike. Good question. I believe QGIS will treat the ‘pies’ as any other label, and resolve conflicts the same way; in other words, choose one more or less arbitrarily. I guess the only thing you could do is make the pies smaller to help alleviate this problem?

Comment from Ian Kirk-Ellis
Time September 19, 2012 at 9:28 am

The easiest way to get a key is to use “snipping tool” in Windows 7 (or similar) to grab the image from within the ‘Diagrams’ tab, this can then be added to the composer as an image.

Comment from franchina
Time November 28, 2012 at 3:35 am

i want to do georeference correctly may i know what is the calculation

Comment from darrencope
Time November 28, 2012 at 5:05 pm

franchina: A quick Google search should provide what you need. For example, to georeference, here’s an example. “Cartographic Mapping” is a pretty broad, vague statement, so you’d have to narrow your question down considerable for anyone to help.

Comment from franchina
Time November 28, 2012 at 3:38 am

i want to do cartographic mapping in qgis may i know what to do?

Pingback from DARREN COPE » 2012 – The Year in Review
Time February 3, 2013 at 4:17 pm

[…] QGIS Diagrams – Pie Charts for Symbols! […]

Comment from Munlin
Time April 30, 2013 at 6:21 am

I am also getting same problem like Anna.
Can anyone resolve it.

Comment from darrencope
Time April 30, 2013 at 6:39 am

Munlin: as per the reply to Anna, it doesn’t seem like there’s a way–try the screenshot method mentioned above.

Comment from CharlesG
Time May 27, 2013 at 9:56 am

Thanks for the post! I’ve been experimenting with diagrams and have noticed a couple of things: 1) it helps to create another column in the attribute table for scale since not all the features may have all the attributes and 2) experiment with the placement of the charts. If they overlap, some of them may not appear. I think this is what happened to me. When I have the charts as “overpoint,” one of my pie charts disappears but when I have it as “free,” it reappears.

Comment from darrencope
Time May 28, 2013 at 7:11 am

Thanks CharlesG; yes, those are great tips! ‘Free’ will allow the label renderer to attempt to move the pie charts around to avoid overlapping, while ‘over point’ will just hide them if they overlap.

Comment from Ashutosh Saxena
Time June 26, 2013 at 1:14 am

Thanks for the post !Well I have just started with QGIS and suffered this problem of only some pie charts being displayed in the image that is made from the composer, the only way to go about it is to simply change the FIXED SIZE of the pie chart circle from mm to the MAP SCALE, and fit the chart at whatever size you want. The problem is removed. But cannot understand why enabling ON THE FLY isn’t doing that when mm scale was being used??

Comment from Nhu
Time January 14, 2014 at 2:21 pm

i’m having quite a time with my pie charts. after merging two layers, the diagrams only show up on one. in fact, it doesn’t emerge at all on one of the layers (alone) what are some possible issues?

Comment from darrencope
Time January 14, 2014 at 4:52 pm

Hi Nhu. Can you explain a bit more? What do you mean by merging two layers? Are you trying to label two layers that overlap? If so, the label conflict detection is likely only showing one of the layers, which may explain your problem.

Comment from Nicole Sigaud
Time May 22, 2014 at 8:08 pm

I’d like to see how I could add a circle sector with 120º, with transparency of, say, 60%, with its vertex in a certain lat/long point. Also, there should have the center angle axis directed to a specific direction. The scope is to plot the transmission range of a cell phone antenna having its azimuth. Is it possible?

Comment from darrencope
Time May 28, 2014 at 7:20 am

Nicole; the Pie Chart labels aren’t likely the best way to do what you are hoping. Take a peek at this post: to see if it helps at all.

Comment from scoop
Time October 17, 2014 at 7:12 am

Is there any way to add stippled or crosshatch fills to the pie chart instead of grey scale or colours. I cannot see how to prepare a map with pie charts which is suitable for publication in black an white. Unfortunately I have more than 3 attributes (black, white and grey) although not in the same pie chart

Comment from darrencope
Time October 20, 2014 at 7:29 am

Unfortunately I don’t see a way to add fill patterns to the pie charts–hopefully that enhancement will come soon. Perhaps you could suggest it as a new feature!

Comment from kilolima
Time November 4, 2014 at 11:36 pm

It’s not clear in qgis, but labelling needs to be enabled in order to get the diagrams to show up. Another poorly documented feature in qgis!

Comment from Siu
Time May 26, 2015 at 11:15 pm

But how do you include the data in the pie charts in a legend?

Comment from darrencope
Time May 27, 2015 at 6:58 am

Siu; at this point, I don’t think there’s any way to do that unfortunately.

Comment from Iain Macbriar
Time August 5, 2015 at 1:27 pm

I too like pie charts as a way of presenting geographical variations. I particularly like what are called spie charts, where the radii of the sectors can vary. I like to keep the angles of the various sectors constant across all of the pies, and vary the radius so that the area of each sector is proportional to the number of people in that category at that location. Not easy to explain this – is there any way in which I can attach an example?

Anyway – I can’t see a way of doing this in QGIS. Any suggestions?

Comment from darrencope
Time August 5, 2015 at 1:34 pm

Hi Iain; Interesting point. I don’t believe there’s a way to create spie charts in QGIS (yet!) but you could always generate the charts separately and manually place them on the map or use them as markers. Obviously not as clean of a solution, but a nice workaround.

Comment from sam
Time September 24, 2015 at 2:39 am

can u pls help me
i cannot display chart using diagram in QGIS 2.6

Comment from darrencope
Time September 25, 2015 at 3:21 pm

At what point are you having an issue?

Comment from Lauri
Time July 11, 2016 at 12:21 am

I came here looking for a way to add scale key to the legend with scaled piecharts. I don’t understand how you could get the scale right of you’re inserting a screencap, and resolution is also not going to be acceptable for print. What you should do instead is create a duplicate of the layer, with the same size scaling for a *marker* that you are using for the diagram, and use this to generate the legend.

Comment from darrencope
Time July 12, 2016 at 1:17 pm

Great idea Lauri!

Comment from Andy
Time April 4, 2018 at 5:27 am

Bit late to the party but feature suggestion….at the moment (QGIS 2.18) there doesn’t seem to be an option to only display the pie-chart (or any diagram) for categorical attributes. I have a point attribute split to 9 classes which i can toggle on/off individually but the pie charts display for all points regardless. Anyone else experienced the problem and found a solution?

Comment from darrencope
Time April 4, 2018 at 8:20 am

Hi Andy. I thought this would be an easy one, but I took a quick look, and didn’t see the data-defined functionality I was expecting! However, a bit of a ‘hack’ solution appears to be adding a new column that contains a ‘1’ if you want the symbol visible, or a ‘0’ if you don’t. Then, on the Diagram tab, go to Appearance > Visibility > uncheck “Show all diagrams” > check off “Data Defined Visibility” > Select your new field. Not ideal, but workable. Note that in 3.x versions of QGIS, this problem is solved under the same tab, Diagrams > Rendering > Data-Defined > Show Diagram > Edit, and then put in your filter (e.g. “Category” in (1,3) or “Category” = 2 or whatever) in the Expression box.

Comment from Andy
Time April 4, 2018 at 10:51 am

Thanks for the rapid response Darren! I think the solutions above would still require manual input to either the attribute tables or to the expressions each time I wanted to select a different category or combination of categories. I was hoping for a dynamic feature that implemented as classes were toggled on/off. My temporary solution is to have 9 separate layers for each category so the pie-chart diagrams turned on/off as each layer did – not ideal but workable on a relatively small set of layers. I’ve had a scan (web and QGIS docs) for an expression that filters or flags only active sub-categories/layers but no joy as yet. There may be a code-based or programmable approach but that’s (currently) beyond my knowledge and expertise. Thanks again.

Comment from darrencope
Time April 10, 2018 at 2:57 pm


I think I understand what you mean now. Yes, your solution is the best one. The only addition would be perhaps to put all of those layers in a group so you can turn them all off at once if you wanted. Cheers!

Write a comment