[{"data":1,"prerenderedAt":1718},["ShallowReactive",2],{"doc:\u002Fpyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002Fadd-pie-chart-diagrams-pyqgis":3},{"id":4,"title":5,"body":6,"description":1707,"extension":1708,"meta":1709,"navigation":286,"path":1714,"seo":1715,"stem":1716,"__hash__":1717},"docs\u002Fpyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002Fadd-pie-chart-diagrams-pyqgis\u002Findex.md","Add Pie Chart Diagrams to a Layer in PyQGIS",{"type":7,"value":8,"toc":1692},"minimark",[9,13,17,26,185,190,215,219,222,562,577,581,584,703,712,768,772,775,947,957,961,964,1131,1145,1149,1152,1221,1321,1334,1338,1341,1504,1513,1517,1520,1550,1554,1568,1572,1606,1610,1619,1623,1633,1643,1649,1655,1659,1688],[10,11,5],"h1",{"id":12},"add-pie-chart-diagrams-to-a-layer-in-pyqgis",[14,15,16],"p",{},"A choropleth shows one value per area. Often the interesting story is a composition: the share of votes for each party in each constituency, the mix of land uses in each municipality, the split of commuting modes per district. QGIS can draw a small chart on every feature — a diagram — and the pie chart is the most familiar form for \"parts of a whole\". Configured carelessly, a map of pies is a cluttered mess; configured well, it shows patterns of composition that no other map type can.",[14,18,19,20,25],{},"This recipe belongs to ",[21,22,24],"a",{"href":23},"\u002Fpyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002F","Diagrams & Charts on Maps",". It builds a pie diagram renderer from Python, sets categories, colours and labels, sizes the pies, places them sensibly, and explains when a different diagram serves better.",[14,27,28],{},[29,30,35,39,43,50,67,76,85,91,97,103,108,112,116,121,125,128,131,137,142,145,148,155,159,163,169,172,175,181],"svg",{"viewBox":31,"role":32,"ariaLabel":33,"xmlns":34},"0 0 760 290","img","The four objects that configure a diagram: chart type, settings with categories and colours, renderer for size, and layer settings for placement","http:\u002F\u002Fwww.w3.org\u002F2000\u002Fsvg",[36,37,38],"title",{},"The objects behind a diagram",[40,41,42],"desc",{},"A diagram on a vector layer is configured through four objects. QgsPieDiagram is the chart type. QgsDiagramSettings holds the categories, which are fields or expressions, their colours and labels, the size and outline. A diagram renderer, single category for fixed size or linearly interpolated for scaled size, combines type and settings. QgsDiagramLayerSettings controls placement, priority and visibility on the layer.",[44,45],"rect",{"x":46,"y":46,"width":47,"height":48,"fill":49},"0","760","290","#f6f3ea",[51,52,53],"defs",{},[54,55,62],"marker",{"id":56,"viewBox":57,"refX":58,"refY":59,"markerWidth":60,"markerHeight":60,"orient":61},"piePartsArrow","0 0 10 10","8","5","7","auto-start-reverse",[63,64],"path",{"d":65,"fill":66},"M0 0 L10 5 L0 10 z","#2f3b35",[68,69,75],"text",{"x":70,"y":71,"style":72,"fill":73,"textAnchor":74},"380","28","text-anchor:middle;font-size:14px;font-family:sans-serif;font-weight:bold","#17211d","middle","Type, settings, renderer, placement",[44,77],{"x":78,"y":79,"width":80,"height":81,"rx":58,"fill":82,"stroke":83,"style":84},"24","56","170","100","#eef7f4","#0f766e","stroke-width:2",[68,86,90],{"x":87,"y":88,"style":89,"fill":83,"textAnchor":74},"109","97.6","text-anchor:middle;font-size:11.0px;font-family:sans-serif;font-weight:bold","QgsPieDiagram",[68,92,96],{"x":87,"y":93,"style":94,"fill":95,"textAnchor":74},"121.6","text-anchor:middle;font-size:10.0px;font-family:sans-serif","#59645f","the chart type",[44,98],{"x":99,"y":79,"width":100,"height":81,"rx":58,"fill":101,"stroke":102,"style":84},"210","190","#eff3ff","#2563eb",[68,104,107],{"x":105,"y":106,"style":89,"fill":102,"textAnchor":74},"305","87.6","QgsDiagramSettings",[68,109,111],{"x":105,"y":110,"style":94,"fill":95,"textAnchor":74},"109.6","categories, colours",[68,113,115],{"x":105,"y":114,"style":94,"fill":95,"textAnchor":74},"131.6","size, outline",[44,117],{"x":118,"y":79,"width":80,"height":81,"rx":58,"fill":119,"stroke":120,"style":84},"416","#fdf2e2","#b45309",[68,122,124],{"x":123,"y":106,"style":89,"fill":120,"textAnchor":74},"501","renderer",[68,126,127],{"x":123,"y":110,"style":94,"fill":95,"textAnchor":74},"fixed or scaled",[68,129,130],{"x":123,"y":114,"style":94,"fill":95,"textAnchor":74},"size",[44,132],{"x":133,"y":79,"width":134,"height":81,"rx":58,"fill":135,"stroke":136,"style":84},"602","134","#e8efe6","#15803d",[68,138,141],{"x":139,"y":106,"style":89,"fill":140,"textAnchor":74},"669","#166534","layer settings",[68,143,144],{"x":139,"y":110,"style":94,"fill":95,"textAnchor":74},"placement",[68,146,147],{"x":139,"y":114,"style":94,"fill":95,"textAnchor":74},"priority",[149,150],"line",{"x1":151,"y1":152,"x2":153,"y2":152,"stroke":66,"style":154},"194","106","206","stroke-width:1.8;marker-end:url(#piePartsArrow)",[149,156],{"x1":157,"y1":152,"x2":158,"y2":152,"stroke":66,"style":154},"400","412",[149,160],{"x1":161,"y1":152,"x2":162,"y2":152,"stroke":66,"style":154},"586","598",[164,165],"circle",{"cx":70,"cy":166,"r":167,"fill":83,"stroke":168,"style":84},"220","46","#fffdf7",[63,170],{"d":171,"fill":120,"stroke":168,"style":84},"M 380 220 L 380 174 A 46 46 0 0 1 424 233 Z",[63,173],{"d":174,"fill":102,"stroke":168,"style":84},"M 380 220 L 424 233 A 46 46 0 0 1 352 257 Z",[68,176,180],{"x":177,"y":99,"style":178,"fill":95,"textAnchor":179},"470","text-anchor:start;font-size:10.5px;font-family:sans-serif","start","one pie per feature,",[68,182,184],{"x":177,"y":183,"style":178,"fill":95,"textAnchor":179},"228","slices from attributes",[186,187,189],"h2",{"id":188},"prerequisites","Prerequisites",[191,192,193,197,212],"ul",{},[194,195,196],"li",{},"QGIS 3.34 LTR or newer, or the QGIS 4 series.",[194,198,199,200,204,205,204,208,211],{},"A polygon or point layer with several numeric fields that are parts of one whole — for example ",[201,202,203],"code",{},"votes_a",", ",[201,206,207],{},"votes_b",[201,209,210],{},"votes_c",", or land-use areas per category.",[194,213,214],{},"Values in comparable units. A pie of a percentage and an absolute count is meaningless.",[186,216,218],{"id":217},"build-a-pie-diagram","Build a pie diagram",[14,220,221],{},"The minimum configuration is a diagram type, settings with at least one category, a renderer, and layer settings. Assigning the renderer and layer settings to the layer makes the pies appear.",[223,224,229],"pre",{"className":225,"code":226,"language":227,"meta":228,"style":228},"language-python shiki shiki-themes github-dark","from qgis.core import (QgsProject, QgsPieDiagram, QgsDiagramSettings,\n                       QgsSingleCategoryDiagramRenderer, QgsDiagramLayerSettings)\nfrom qgis.PyQt.QtGui import QColor\nfrom qgis.PyQt.QtCore import QSizeF\n\ndistricts = QgsProject.instance().mapLayersByName(\"districts\")[0]\n\nsettings = QgsDiagramSettings()\nsettings.categoryAttributes = ['\"walk\"', '\"cycle\"', '\"transit\"', '\"car\"']\nsettings.categoryColors = [QColor(\"#15803d\"), QColor(\"#0f766e\"),\n                           QColor(\"#2563eb\"), QColor(\"#b45309\")]\nsettings.categoryLabels = [\"walk\", \"cycle\", \"transit\", \"car\"]\nsettings.size = QSizeF(9, 9)                       # millimetres\nsettings.penColor = QColor(\"#ffffff\")\nsettings.penWidth = 0.3\nsettings.enabled = True\n\nrenderer = QgsSingleCategoryDiagramRenderer()\nrenderer.setDiagram(QgsPieDiagram())\nrenderer.setDiagramSettings(settings)\ndistricts.setDiagramRenderer(renderer)\n\nlayer_settings = QgsDiagramLayerSettings()\nlayer_settings.setPlacement(QgsDiagramLayerSettings.OverPoint)\ndistricts.setDiagramLayerSettings(layer_settings)\ndistricts.triggerRepaint()\n","python","",[201,230,231,249,255,268,281,288,313,318,329,360,383,400,430,455,472,483,494,499,510,516,522,528,533,544,550,556],{"__ignoreMap":228},[232,233,235,239,243,246],"span",{"class":149,"line":234},1,[232,236,238],{"class":237},"snl16","from",[232,240,242],{"class":241},"s95oV"," qgis.core ",[232,244,245],{"class":237},"import",[232,247,248],{"class":241}," (QgsProject, QgsPieDiagram, QgsDiagramSettings,\n",[232,250,252],{"class":149,"line":251},2,[232,253,254],{"class":241},"                       QgsSingleCategoryDiagramRenderer, QgsDiagramLayerSettings)\n",[232,256,258,260,263,265],{"class":149,"line":257},3,[232,259,238],{"class":237},[232,261,262],{"class":241}," qgis.PyQt.QtGui ",[232,264,245],{"class":237},[232,266,267],{"class":241}," QColor\n",[232,269,271,273,276,278],{"class":149,"line":270},4,[232,272,238],{"class":237},[232,274,275],{"class":241}," qgis.PyQt.QtCore ",[232,277,245],{"class":237},[232,279,280],{"class":241}," QSizeF\n",[232,282,284],{"class":149,"line":283},5,[232,285,287],{"emptyLinePlaceholder":286},true,"\n",[232,289,291,294,297,300,304,307,310],{"class":149,"line":290},6,[232,292,293],{"class":241},"districts ",[232,295,296],{"class":237},"=",[232,298,299],{"class":241}," QgsProject.instance().mapLayersByName(",[232,301,303],{"class":302},"sU2Wk","\"districts\"",[232,305,306],{"class":241},")[",[232,308,46],{"class":309},"sDLfK",[232,311,312],{"class":241},"]\n",[232,314,316],{"class":149,"line":315},7,[232,317,287],{"emptyLinePlaceholder":286},[232,319,321,324,326],{"class":149,"line":320},8,[232,322,323],{"class":241},"settings ",[232,325,296],{"class":237},[232,327,328],{"class":241}," QgsDiagramSettings()\n",[232,330,332,335,337,340,343,345,348,350,353,355,358],{"class":149,"line":331},9,[232,333,334],{"class":241},"settings.categoryAttributes ",[232,336,296],{"class":237},[232,338,339],{"class":241}," [",[232,341,342],{"class":302},"'\"walk\"'",[232,344,204],{"class":241},[232,346,347],{"class":302},"'\"cycle\"'",[232,349,204],{"class":241},[232,351,352],{"class":302},"'\"transit\"'",[232,354,204],{"class":241},[232,356,357],{"class":302},"'\"car\"'",[232,359,312],{"class":241},[232,361,363,366,368,371,374,377,380],{"class":149,"line":362},10,[232,364,365],{"class":241},"settings.categoryColors ",[232,367,296],{"class":237},[232,369,370],{"class":241}," [QColor(",[232,372,373],{"class":302},"\"#15803d\"",[232,375,376],{"class":241},"), QColor(",[232,378,379],{"class":302},"\"#0f766e\"",[232,381,382],{"class":241},"),\n",[232,384,386,389,392,394,397],{"class":149,"line":385},11,[232,387,388],{"class":241},"                           QColor(",[232,390,391],{"class":302},"\"#2563eb\"",[232,393,376],{"class":241},[232,395,396],{"class":302},"\"#b45309\"",[232,398,399],{"class":241},")]\n",[232,401,403,406,408,410,413,415,418,420,423,425,428],{"class":149,"line":402},12,[232,404,405],{"class":241},"settings.categoryLabels ",[232,407,296],{"class":237},[232,409,339],{"class":241},[232,411,412],{"class":302},"\"walk\"",[232,414,204],{"class":241},[232,416,417],{"class":302},"\"cycle\"",[232,419,204],{"class":241},[232,421,422],{"class":302},"\"transit\"",[232,424,204],{"class":241},[232,426,427],{"class":302},"\"car\"",[232,429,312],{"class":241},[232,431,433,436,438,441,444,446,448,451],{"class":149,"line":432},13,[232,434,435],{"class":241},"settings.size ",[232,437,296],{"class":237},[232,439,440],{"class":241}," QSizeF(",[232,442,443],{"class":309},"9",[232,445,204],{"class":241},[232,447,443],{"class":309},[232,449,450],{"class":241},")                       ",[232,452,454],{"class":453},"sjoCn","# millimetres\n",[232,456,458,461,463,466,469],{"class":149,"line":457},14,[232,459,460],{"class":241},"settings.penColor ",[232,462,296],{"class":237},[232,464,465],{"class":241}," QColor(",[232,467,468],{"class":302},"\"#ffffff\"",[232,470,471],{"class":241},")\n",[232,473,475,478,480],{"class":149,"line":474},15,[232,476,477],{"class":241},"settings.penWidth ",[232,479,296],{"class":237},[232,481,482],{"class":309}," 0.3\n",[232,484,486,489,491],{"class":149,"line":485},16,[232,487,488],{"class":241},"settings.enabled ",[232,490,296],{"class":237},[232,492,493],{"class":309}," True\n",[232,495,497],{"class":149,"line":496},17,[232,498,287],{"emptyLinePlaceholder":286},[232,500,502,505,507],{"class":149,"line":501},18,[232,503,504],{"class":241},"renderer ",[232,506,296],{"class":237},[232,508,509],{"class":241}," QgsSingleCategoryDiagramRenderer()\n",[232,511,513],{"class":149,"line":512},19,[232,514,515],{"class":241},"renderer.setDiagram(QgsPieDiagram())\n",[232,517,519],{"class":149,"line":518},20,[232,520,521],{"class":241},"renderer.setDiagramSettings(settings)\n",[232,523,525],{"class":149,"line":524},21,[232,526,527],{"class":241},"districts.setDiagramRenderer(renderer)\n",[232,529,531],{"class":149,"line":530},22,[232,532,287],{"emptyLinePlaceholder":286},[232,534,536,539,541],{"class":149,"line":535},23,[232,537,538],{"class":241},"layer_settings ",[232,540,296],{"class":237},[232,542,543],{"class":241}," QgsDiagramLayerSettings()\n",[232,545,547],{"class":149,"line":546},24,[232,548,549],{"class":241},"layer_settings.setPlacement(QgsDiagramLayerSettings.OverPoint)\n",[232,551,553],{"class":149,"line":552},25,[232,554,555],{"class":241},"districts.setDiagramLayerSettings(layer_settings)\n",[232,557,559],{"class":149,"line":558},26,[232,560,561],{"class":241},"districts.triggerRepaint()\n",[14,563,564,568,569,572,573,576],{},[565,566,567],"strong",{},"Breakdown:"," ",[201,570,571],{},"categoryAttributes"," takes expressions, not bare field names — hence the double quotes around each field, which is how expressions reference fields. Colours and labels are parallel lists in the same order as the attributes; labels appear in the legend. Size is in millimetres by default, so a 9 mm pie stays the same size on screen at every zoom level. A thin white outline separates slices and keeps neighbouring pies distinct. ",[201,574,575],{},"OverPoint"," centres each pie on the feature's centroid or point.",[186,578,580],{"id":579},"use-expressions-as-categories","Use expressions as categories",[14,582,583],{},"Categories do not have to be raw fields. Any expression works — combining fields, converting units, or computing shares — which keeps derived values out of the attribute table.",[223,585,587],{"className":225,"code":586,"language":227,"meta":228,"style":228},"settings.categoryAttributes = [\n    '\"walk\" + \"cycle\"',                 # active travel combined\n    '\"bus\" + \"tram\" + \"rail\"',          # public transport combined\n    '\"car_driver\" + \"car_passenger\"',\n    'coalesce(\"other\", 0)',\n]\nsettings.categoryLabels = [\"active\", \"public transport\", \"car\", \"other\"]\nsettings.categoryColors = [QColor(\"#15803d\"), QColor(\"#2563eb\"),\n                           QColor(\"#b45309\"), QColor(\"#59645f\")]\nrenderer.setDiagramSettings(settings)\ndistricts.triggerRepaint()\n",[201,588,589,598,609,620,628,635,639,666,682,695,699],{"__ignoreMap":228},[232,590,591,593,595],{"class":149,"line":234},[232,592,334],{"class":241},[232,594,296],{"class":237},[232,596,597],{"class":241}," [\n",[232,599,600,603,606],{"class":149,"line":251},[232,601,602],{"class":302},"    '\"walk\" + \"cycle\"'",[232,604,605],{"class":241},",                 ",[232,607,608],{"class":453},"# active travel combined\n",[232,610,611,614,617],{"class":149,"line":257},[232,612,613],{"class":302},"    '\"bus\" + \"tram\" + \"rail\"'",[232,615,616],{"class":241},",          ",[232,618,619],{"class":453},"# public transport combined\n",[232,621,622,625],{"class":149,"line":270},[232,623,624],{"class":302},"    '\"car_driver\" + \"car_passenger\"'",[232,626,627],{"class":241},",\n",[232,629,630,633],{"class":149,"line":283},[232,631,632],{"class":302},"    'coalesce(\"other\", 0)'",[232,634,627],{"class":241},[232,636,637],{"class":149,"line":290},[232,638,312],{"class":241},[232,640,641,643,645,647,650,652,655,657,659,661,664],{"class":149,"line":315},[232,642,405],{"class":241},[232,644,296],{"class":237},[232,646,339],{"class":241},[232,648,649],{"class":302},"\"active\"",[232,651,204],{"class":241},[232,653,654],{"class":302},"\"public transport\"",[232,656,204],{"class":241},[232,658,427],{"class":302},[232,660,204],{"class":241},[232,662,663],{"class":302},"\"other\"",[232,665,312],{"class":241},[232,667,668,670,672,674,676,678,680],{"class":149,"line":320},[232,669,365],{"class":241},[232,671,296],{"class":237},[232,673,370],{"class":241},[232,675,373],{"class":302},[232,677,376],{"class":241},[232,679,391],{"class":302},[232,681,382],{"class":241},[232,683,684,686,688,690,693],{"class":149,"line":331},[232,685,388],{"class":241},[232,687,396],{"class":302},[232,689,376],{"class":241},[232,691,692],{"class":302},"\"#59645f\"",[232,694,399],{"class":241},[232,696,697],{"class":149,"line":362},[232,698,521],{"class":241},[232,700,701],{"class":149,"line":385},[232,702,561],{"class":241},[14,704,705,707,708,711],{},[565,706,567],{}," Combining detailed fields into four or five broad groups is the single most effective way to make pies readable: beyond about five slices, small slices become indistinguishable. ",[201,709,710],{},"coalesce"," turns NULLs into zero so a missing value does not remove the whole pie — in an expression, any arithmetic involving NULL yields NULL. Because the expressions are stored in the layer's style, the grouping travels with a saved QML or project.",[14,713,714],{},[29,715,718,721,724,727,730,734,738,741,744,747,751,756,759,762,765],{"viewBox":716,"role":32,"ariaLabel":717,"xmlns":34},"0 0 760 240","A pie with nine thin slices compared with the same data grouped into four readable slices",[36,719,720],{},"Fewer slices read better",[40,722,723],{},"Two pies for the same district. The first has nine slices from detailed mode fields, several thinner than a few degrees and impossible to compare. The second groups them into four broad categories, each wide enough to see and compare with neighbouring pies.",[44,725],{"x":46,"y":46,"width":47,"height":726,"fill":49},"240",[68,728,729],{"x":70,"y":71,"style":72,"fill":73,"textAnchor":74},"Group detailed fields into four or five slices",[164,731],{"cx":100,"cy":732,"r":733,"fill":95,"stroke":168,"style":84},"130","70",[63,735],{"d":736,"fill":136,"stroke":168,"style":737},"M 190 130 L 190 60 A 70 70 0 0 1 240 81 Z","stroke-width:1.5",[63,739],{"d":740,"fill":83,"stroke":168,"style":737},"M 190 130 L 240 81 A 70 70 0 0 1 258 112 Z",[63,742],{"d":743,"fill":102,"stroke":168,"style":737},"M 190 130 L 258 112 A 70 70 0 0 1 260 130 Z",[63,745],{"d":746,"fill":120,"stroke":168,"style":737},"M 190 130 L 260 130 A 70 70 0 0 1 256 152 Z",[63,748],{"d":749,"fill":750,"stroke":168,"style":737},"M 190 130 L 256 152 A 70 70 0 0 1 228 189 Z","#b91c1c",[68,752,755],{"x":100,"y":753,"style":754,"fill":95,"textAnchor":74},"226","text-anchor:middle;font-size:10.5px;font-family:sans-serif","nine slices: unreadable",[164,757],{"cx":758,"cy":732,"r":733,"fill":120,"stroke":168,"style":84},"570",[63,760],{"d":761,"fill":136,"stroke":168,"style":84},"M 570 130 L 570 60 A 70 70 0 0 1 636 154 Z",[63,763],{"d":764,"fill":102,"stroke":168,"style":84},"M 570 130 L 636 154 A 70 70 0 0 1 528 186 Z",[68,766,767],{"x":758,"y":753,"style":754,"fill":140,"textAnchor":74},"four groups: comparable",[186,769,771],{"id":770},"choose-colours-that-fit-the-map","Choose colours that fit the map",[14,773,774],{},"Diagram colours compete with the base map and any fill colours underneath. Qualitative colours with similar lightness, an unobtrusive base layer and consistent colours for the same categories across all maps of a project make diagrams legible.",[223,776,778],{"className":225,"code":777,"language":227,"meta":228,"style":228},"from qgis.core import QgsStyle\n\nramp = QgsStyle.defaultStyle().colorRamp(\"Set2\")\nn = len(settings.categoryAttributes)\nsettings.categoryColors = [ramp.color(i \u002F max(n - 1, 1)) for i in range(n)]\nrenderer.setDiagramSettings(settings)\n\n# a quiet base: light grey fill, thin outline\nfrom qgis.core import QgsFillSymbol, QgsSingleSymbolRenderer\nbase = QgsFillSymbol.createSimple({\"color\": \"#f0ebdd\", \"outline_color\": \"#b8b1a0\",\n                                   \"outline_width\": \"0.2\"})\ndistricts.setRenderer(QgsSingleSymbolRenderer(base))\ndistricts.triggerRepaint()\n",[201,779,780,791,795,810,823,870,874,878,883,894,925,938,943],{"__ignoreMap":228},[232,781,782,784,786,788],{"class":149,"line":234},[232,783,238],{"class":237},[232,785,242],{"class":241},[232,787,245],{"class":237},[232,789,790],{"class":241}," QgsStyle\n",[232,792,793],{"class":149,"line":251},[232,794,287],{"emptyLinePlaceholder":286},[232,796,797,800,802,805,808],{"class":149,"line":257},[232,798,799],{"class":241},"ramp ",[232,801,296],{"class":237},[232,803,804],{"class":241}," QgsStyle.defaultStyle().colorRamp(",[232,806,807],{"class":302},"\"Set2\"",[232,809,471],{"class":241},[232,811,812,815,817,820],{"class":149,"line":270},[232,813,814],{"class":241},"n ",[232,816,296],{"class":237},[232,818,819],{"class":309}," len",[232,821,822],{"class":241},"(settings.categoryAttributes)\n",[232,824,825,827,829,832,835,838,841,844,847,849,852,855,858,861,864,867],{"class":149,"line":283},[232,826,365],{"class":241},[232,828,296],{"class":237},[232,830,831],{"class":241}," [ramp.color(i ",[232,833,834],{"class":237},"\u002F",[232,836,837],{"class":309}," max",[232,839,840],{"class":241},"(n ",[232,842,843],{"class":237},"-",[232,845,846],{"class":309}," 1",[232,848,204],{"class":241},[232,850,851],{"class":309},"1",[232,853,854],{"class":241},")) ",[232,856,857],{"class":237},"for",[232,859,860],{"class":241}," i ",[232,862,863],{"class":237},"in",[232,865,866],{"class":309}," range",[232,868,869],{"class":241},"(n)]\n",[232,871,872],{"class":149,"line":290},[232,873,521],{"class":241},[232,875,876],{"class":149,"line":315},[232,877,287],{"emptyLinePlaceholder":286},[232,879,880],{"class":149,"line":320},[232,881,882],{"class":453},"# a quiet base: light grey fill, thin outline\n",[232,884,885,887,889,891],{"class":149,"line":331},[232,886,238],{"class":237},[232,888,242],{"class":241},[232,890,245],{"class":237},[232,892,893],{"class":241}," QgsFillSymbol, QgsSingleSymbolRenderer\n",[232,895,896,899,901,904,907,910,913,915,918,920,923],{"class":149,"line":362},[232,897,898],{"class":241},"base ",[232,900,296],{"class":237},[232,902,903],{"class":241}," QgsFillSymbol.createSimple({",[232,905,906],{"class":302},"\"color\"",[232,908,909],{"class":241},": ",[232,911,912],{"class":302},"\"#f0ebdd\"",[232,914,204],{"class":241},[232,916,917],{"class":302},"\"outline_color\"",[232,919,909],{"class":241},[232,921,922],{"class":302},"\"#b8b1a0\"",[232,924,627],{"class":241},[232,926,927,930,932,935],{"class":149,"line":385},[232,928,929],{"class":302},"                                   \"outline_width\"",[232,931,909],{"class":241},[232,933,934],{"class":302},"\"0.2\"",[232,936,937],{"class":241},"})\n",[232,939,940],{"class":149,"line":402},[232,941,942],{"class":241},"districts.setRenderer(QgsSingleSymbolRenderer(base))\n",[232,944,945],{"class":149,"line":432},[232,946,561],{"class":241},[14,948,949,951,952,956],{},[565,950,567],{}," Sampling a qualitative ramp such as Set2 at evenly spaced positions gives distinct colours of similar weight, so no category dominates visually because of its hue. Putting the diagrams over a pale, neutral fill — rather than over a choropleth — keeps attention on the slices; a choropleth beneath pies forces readers to decode two colour schemes at once. If the same categories appear on other maps, reuse the exact colours, for example by storing them in a shared QML style as in ",[21,953,955],{"href":954},"\u002Fpyqgis-cartography-visualization\u002Fprogrammatic-layer-styling\u002Fsave-and-load-qml-style-pyqgis\u002F","saving and loading QML styles",".",[186,958,960],{"id":959},"size-pies-by-a-total","Size pies by a total",[14,962,963],{},"With fixed sizes, every pie shows composition only. Scaling pie area by a total — population, total votes — adds magnitude, so large districts are visible as large pies.",[223,965,967],{"className":225,"code":966,"language":227,"meta":228,"style":228},"from qgis.core import QgsLinearlyInterpolatedDiagramRenderer\n\nscaled = QgsLinearlyInterpolatedDiagramRenderer()\nscaled.setDiagram(QgsPieDiagram())\nscaled.setDiagramSettings(settings)\nscaled.setClassificationAttributeExpression('\"walk\" + \"cycle\" + \"transit\" + \"car\"')\nmax_total = max(f[\"walk\"] + f[\"cycle\"] + f[\"transit\"] + f[\"car\"] for f in districts.getFeatures())\nscaled.setLowerValue(0)\nscaled.setUpperValue(max_total)\nscaled.setLowerSize(QSizeF(0, 0))\nscaled.setUpperSize(QSizeF(16, 16))\nsettings.scaleByArea = True\nscaled.setDiagramSettings(settings)\ndistricts.setDiagramRenderer(scaled)\ndistricts.triggerRepaint()\n",[201,968,969,980,984,994,999,1004,1014,1067,1076,1081,1095,1109,1118,1122,1127],{"__ignoreMap":228},[232,970,971,973,975,977],{"class":149,"line":234},[232,972,238],{"class":237},[232,974,242],{"class":241},[232,976,245],{"class":237},[232,978,979],{"class":241}," QgsLinearlyInterpolatedDiagramRenderer\n",[232,981,982],{"class":149,"line":251},[232,983,287],{"emptyLinePlaceholder":286},[232,985,986,989,991],{"class":149,"line":257},[232,987,988],{"class":241},"scaled ",[232,990,296],{"class":237},[232,992,993],{"class":241}," QgsLinearlyInterpolatedDiagramRenderer()\n",[232,995,996],{"class":149,"line":270},[232,997,998],{"class":241},"scaled.setDiagram(QgsPieDiagram())\n",[232,1000,1001],{"class":149,"line":283},[232,1002,1003],{"class":241},"scaled.setDiagramSettings(settings)\n",[232,1005,1006,1009,1012],{"class":149,"line":290},[232,1007,1008],{"class":241},"scaled.setClassificationAttributeExpression(",[232,1010,1011],{"class":302},"'\"walk\" + \"cycle\" + \"transit\" + \"car\"'",[232,1013,471],{"class":241},[232,1015,1016,1019,1021,1023,1026,1028,1031,1034,1037,1039,1041,1043,1045,1047,1049,1051,1053,1055,1057,1059,1062,1064],{"class":149,"line":315},[232,1017,1018],{"class":241},"max_total ",[232,1020,296],{"class":237},[232,1022,837],{"class":309},[232,1024,1025],{"class":241},"(f[",[232,1027,412],{"class":302},[232,1029,1030],{"class":241},"] ",[232,1032,1033],{"class":237},"+",[232,1035,1036],{"class":241}," f[",[232,1038,417],{"class":302},[232,1040,1030],{"class":241},[232,1042,1033],{"class":237},[232,1044,1036],{"class":241},[232,1046,422],{"class":302},[232,1048,1030],{"class":241},[232,1050,1033],{"class":237},[232,1052,1036],{"class":241},[232,1054,427],{"class":302},[232,1056,1030],{"class":241},[232,1058,857],{"class":237},[232,1060,1061],{"class":241}," f ",[232,1063,863],{"class":237},[232,1065,1066],{"class":241}," districts.getFeatures())\n",[232,1068,1069,1072,1074],{"class":149,"line":320},[232,1070,1071],{"class":241},"scaled.setLowerValue(",[232,1073,46],{"class":309},[232,1075,471],{"class":241},[232,1077,1078],{"class":149,"line":331},[232,1079,1080],{"class":241},"scaled.setUpperValue(max_total)\n",[232,1082,1083,1086,1088,1090,1092],{"class":149,"line":362},[232,1084,1085],{"class":241},"scaled.setLowerSize(QSizeF(",[232,1087,46],{"class":309},[232,1089,204],{"class":241},[232,1091,46],{"class":309},[232,1093,1094],{"class":241},"))\n",[232,1096,1097,1100,1103,1105,1107],{"class":149,"line":385},[232,1098,1099],{"class":241},"scaled.setUpperSize(QSizeF(",[232,1101,1102],{"class":309},"16",[232,1104,204],{"class":241},[232,1106,1102],{"class":309},[232,1108,1094],{"class":241},[232,1110,1111,1114,1116],{"class":149,"line":402},[232,1112,1113],{"class":241},"settings.scaleByArea ",[232,1115,296],{"class":237},[232,1117,493],{"class":309},[232,1119,1120],{"class":149,"line":432},[232,1121,1003],{"class":241},[232,1123,1124],{"class":149,"line":457},[232,1125,1126],{"class":241},"districts.setDiagramRenderer(scaled)\n",[232,1128,1129],{"class":149,"line":474},[232,1130,561],{"class":241},[14,1132,1133,1135,1136,1139,1140,1144],{},[565,1134,567],{}," The linearly interpolated renderer maps a value range to a size range. Starting both at zero means a district with half the maximum total gets half the area — but only with ",[201,1137,1138],{},"scaleByArea"," set, which interpolates area rather than diameter; scaling diameter makes large values look far bigger than they are. ",[21,1141,1143],{"href":1142},"\u002Fpyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002Fsize-diagrams-by-attribute-pyqgis\u002F","Sizing diagrams by attribute"," covers the choices and adds a size legend.",[186,1146,1148],{"id":1147},"place-pies-without-clutter","Place pies without clutter",[14,1150,1151],{},"Pies on small, dense polygons overlap. Layer settings control where each pie sits, whether overlapping ones are hidden, and which win when they collide.",[14,1153,1154],{},[29,1155,1158,1161,1164,1167,1170,1173,1178,1182,1186,1190,1193,1196,1199,1202,1205,1208,1212,1215,1218],{"viewBox":1156,"role":32,"ariaLabel":1157,"xmlns":34},"0 0 760 222","Diagram placement options: over or around the point, showing all or dropping colliding pies by priority, and obstacle settings for labels",[36,1159,1160],{},"Placement and collision options",[40,1162,1163],{},"Over point places each pie on the feature's centroid or point. Around point offsets it at a set distance. Show all diagrams draws every pie even if they overlap, otherwise colliding diagrams are dropped by priority. Obstacle settings let labels avoid diagrams. A z-index orders diagrams relative to labels.",[44,1165],{"x":46,"y":46,"width":47,"height":1166,"fill":49},"222",[68,1168,1169],{"x":70,"y":71,"style":72,"fill":73,"textAnchor":74},"Where pies go, and what happens when they collide",[44,1171],{"x":78,"y":79,"width":1166,"height":1172,"rx":58,"fill":82,"stroke":83,"style":84},"150",[68,1174,144],{"x":1175,"y":1176,"style":1177,"fill":83,"textAnchor":74},"135","92.78","text-anchor:middle;font-size:11.5px;font-family:sans-serif;font-weight:bold",[68,1179,1181],{"x":1175,"y":1180,"style":754,"fill":66,"textAnchor":74},"120.78","over point",[68,1183,1185],{"x":1175,"y":1184,"style":754,"fill":66,"textAnchor":74},"148.78","around point",[68,1187,1189],{"x":1175,"y":1188,"style":754,"fill":95,"textAnchor":74},"176.78","distance in mm",[44,1191],{"x":1192,"y":79,"width":1166,"height":1172,"rx":58,"fill":101,"stroke":102,"style":84},"269",[68,1194,1195],{"x":70,"y":1176,"style":1177,"fill":102,"textAnchor":74},"collisions",[68,1197,1198],{"x":70,"y":1180,"style":754,"fill":66,"textAnchor":74},"show all, or",[68,1200,1201],{"x":70,"y":1184,"style":754,"fill":66,"textAnchor":74},"drop by priority",[68,1203,1204],{"x":70,"y":1188,"style":754,"fill":95,"textAnchor":74},"1 to 10",[44,1206],{"x":1207,"y":79,"width":1166,"height":1172,"rx":58,"fill":119,"stroke":120,"style":84},"514",[68,1209,1211],{"x":1210,"y":1176,"style":1177,"fill":120,"textAnchor":74},"625","with labels",[68,1213,1214],{"x":1210,"y":1180,"style":754,"fill":66,"textAnchor":74},"diagrams as obstacles",[68,1216,1217],{"x":1210,"y":1184,"style":754,"fill":66,"textAnchor":74},"z-index ordering",[68,1219,1220],{"x":1210,"y":1188,"style":754,"fill":95,"textAnchor":74},"labels avoid pies",[223,1222,1224],{"className":225,"code":1223,"language":227,"meta":228,"style":228},"ls = QgsDiagramLayerSettings()\nls.setPlacement(QgsDiagramLayerSettings.OverPoint)\nls.setShowAllDiagrams(False)          # drop pies that would overlap others\nls.setPriority(5)\nls.setZIndex(1)\ndistricts.setDiagramLayerSettings(ls)\n\nsettings.scaleBasedVisibility = True\nsettings.minimumScale = 250000        # hide when zoomed out beyond 1:250,000\nsettings.maximumScale = 0\nrenderer.setDiagramSettings(settings)\ndistricts.triggerRepaint()\n",[201,1225,1226,1235,1240,1254,1263,1272,1277,1281,1290,1303,1313,1317],{"__ignoreMap":228},[232,1227,1228,1231,1233],{"class":149,"line":234},[232,1229,1230],{"class":241},"ls ",[232,1232,296],{"class":237},[232,1234,543],{"class":241},[232,1236,1237],{"class":149,"line":251},[232,1238,1239],{"class":241},"ls.setPlacement(QgsDiagramLayerSettings.OverPoint)\n",[232,1241,1242,1245,1248,1251],{"class":149,"line":257},[232,1243,1244],{"class":241},"ls.setShowAllDiagrams(",[232,1246,1247],{"class":309},"False",[232,1249,1250],{"class":241},")          ",[232,1252,1253],{"class":453},"# drop pies that would overlap others\n",[232,1255,1256,1259,1261],{"class":149,"line":270},[232,1257,1258],{"class":241},"ls.setPriority(",[232,1260,59],{"class":309},[232,1262,471],{"class":241},[232,1264,1265,1268,1270],{"class":149,"line":283},[232,1266,1267],{"class":241},"ls.setZIndex(",[232,1269,851],{"class":309},[232,1271,471],{"class":241},[232,1273,1274],{"class":149,"line":290},[232,1275,1276],{"class":241},"districts.setDiagramLayerSettings(ls)\n",[232,1278,1279],{"class":149,"line":315},[232,1280,287],{"emptyLinePlaceholder":286},[232,1282,1283,1286,1288],{"class":149,"line":320},[232,1284,1285],{"class":241},"settings.scaleBasedVisibility ",[232,1287,296],{"class":237},[232,1289,493],{"class":309},[232,1291,1292,1295,1297,1300],{"class":149,"line":331},[232,1293,1294],{"class":241},"settings.minimumScale ",[232,1296,296],{"class":237},[232,1298,1299],{"class":309}," 250000",[232,1301,1302],{"class":453},"        # hide when zoomed out beyond 1:250,000\n",[232,1304,1305,1308,1310],{"class":149,"line":362},[232,1306,1307],{"class":241},"settings.maximumScale ",[232,1309,296],{"class":237},[232,1311,1312],{"class":309}," 0\n",[232,1314,1315],{"class":149,"line":385},[232,1316,521],{"class":241},[232,1318,1319],{"class":149,"line":402},[232,1320,561],{"class":241},[14,1322,1323,1325,1326,1329,1330,1333],{},[565,1324,567],{}," With ",[201,1327,1328],{},"setShowAllDiagrams(False)",", the labelling engine treats diagrams like labels: where two would overlap, the lower-priority one is not drawn. That keeps the map readable at the cost of some missing pies, which is why it is usually combined with scale-based visibility so pies only appear when there is room. On a layer with labels, the label engine also uses diagrams as obstacles, so names are moved off the pies instead of printed across them. Scale limits use the map scale denominator; ",[201,1331,1332],{},"minimumScale"," is the most zoomed-out scale at which pies still show.",[186,1335,1337],{"id":1336},"check-the-totals-behind-each-pie","Check the totals behind each pie",[14,1339,1340],{},"A pie implies that its slices make up a whole. If the category fields do not add up to the real total — because a minor category was left out, or because some respondents gave no answer — every pie silently misrepresents its district. A quick comparison against a total field catches this before the map is published.",[223,1342,1344],{"className":225,"code":1343,"language":227,"meta":228,"style":228},"gaps = []\nfor f in districts.getFeatures():\n    parts = sum((f[n] or 0) for n in (\"walk\", \"cycle\", \"transit\", \"car\"))\n    total = f[\"commuters_total\"] or 0\n    if total and abs(parts - total) \u002F total > 0.02:\n        gaps.append((f[\"district\"], parts, total))\nprint(len(gaps), \"districts where the slices miss more than 2 % of the total\")\n",[201,1345,1346,1356,1367,1415,1433,1468,1479],{"__ignoreMap":228},[232,1347,1348,1351,1353],{"class":149,"line":234},[232,1349,1350],{"class":241},"gaps ",[232,1352,296],{"class":237},[232,1354,1355],{"class":241}," []\n",[232,1357,1358,1360,1362,1364],{"class":149,"line":251},[232,1359,857],{"class":237},[232,1361,1061],{"class":241},[232,1363,863],{"class":237},[232,1365,1366],{"class":241}," districts.getFeatures():\n",[232,1368,1369,1372,1374,1377,1380,1383,1386,1389,1391,1394,1396,1399,1401,1403,1405,1407,1409,1411,1413],{"class":149,"line":257},[232,1370,1371],{"class":241},"    parts ",[232,1373,296],{"class":237},[232,1375,1376],{"class":309}," sum",[232,1378,1379],{"class":241},"((f[n] ",[232,1381,1382],{"class":237},"or",[232,1384,1385],{"class":309}," 0",[232,1387,1388],{"class":241},") ",[232,1390,857],{"class":237},[232,1392,1393],{"class":241}," n ",[232,1395,863],{"class":237},[232,1397,1398],{"class":241}," (",[232,1400,412],{"class":302},[232,1402,204],{"class":241},[232,1404,417],{"class":302},[232,1406,204],{"class":241},[232,1408,422],{"class":302},[232,1410,204],{"class":241},[232,1412,427],{"class":302},[232,1414,1094],{"class":241},[232,1416,1417,1420,1422,1424,1427,1429,1431],{"class":149,"line":270},[232,1418,1419],{"class":241},"    total ",[232,1421,296],{"class":237},[232,1423,1036],{"class":241},[232,1425,1426],{"class":302},"\"commuters_total\"",[232,1428,1030],{"class":241},[232,1430,1382],{"class":237},[232,1432,1312],{"class":309},[232,1434,1435,1438,1441,1444,1447,1450,1452,1455,1457,1459,1462,1465],{"class":149,"line":283},[232,1436,1437],{"class":237},"    if",[232,1439,1440],{"class":241}," total ",[232,1442,1443],{"class":237},"and",[232,1445,1446],{"class":309}," abs",[232,1448,1449],{"class":241},"(parts ",[232,1451,843],{"class":237},[232,1453,1454],{"class":241}," total) ",[232,1456,834],{"class":237},[232,1458,1440],{"class":241},[232,1460,1461],{"class":237},">",[232,1463,1464],{"class":309}," 0.02",[232,1466,1467],{"class":241},":\n",[232,1469,1470,1473,1476],{"class":149,"line":290},[232,1471,1472],{"class":241},"        gaps.append((f[",[232,1474,1475],{"class":302},"\"district\"",[232,1477,1478],{"class":241},"], parts, total))\n",[232,1480,1481,1484,1487,1490,1493,1496,1499,1502],{"class":149,"line":315},[232,1482,1483],{"class":309},"print",[232,1485,1486],{"class":241},"(",[232,1488,1489],{"class":309},"len",[232,1491,1492],{"class":241},"(gaps), ",[232,1494,1495],{"class":302},"\"districts where the slices miss more than 2 ",[232,1497,1498],{"class":309},"% o",[232,1500,1501],{"class":302},"f the total\"",[232,1503,471],{"class":241},[14,1505,1506,1508,1509,1512],{},[565,1507,567],{}," Comparing the sum of slice fields with an independent total, where the data has one, reveals missing categories and data errors. When the difference is real — people who work from home, for instance — add it as its own slice, computed in an expression such as ",[201,1510,1511],{},"\"commuters_total\" - (\"walk\" + \"cycle\" + \"transit\" + \"car\")",", rather than letting the visible slices claim the whole. A pie whose slices are honest about \"other\" and \"not stated\" is always better than one that quietly rescales the rest.",[186,1514,1516],{"id":1515},"when-a-pie-is-the-wrong-chart","When a pie is the wrong chart",[14,1518,1519],{},"Pies work for two to five parts of one whole, compared roughly. They are poor at precise comparison between features — people judge angles badly — and useless when the parts do not sum to a meaningful total.",[191,1521,1522,1534,1544],{},[194,1523,1524,1525,1528,1529,1533],{},"To compare ",[565,1526,1527],{},"the same category across features",", use ",[21,1530,1532],{"href":1531},"\u002Fpyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002Fadd-histogram-bar-diagrams-pyqgis\u002F","histogram diagrams",", where bar lengths are easy to compare.",[194,1535,1536,1537,1528,1540,956],{},"To show ",[565,1538,1539],{},"composition and total together on a precise scale",[21,1541,1543],{"href":1542},"\u002Fpyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002Fadd-stacked-bar-diagrams-pyqgis\u002F","stacked bar diagrams",[194,1545,1536,1546,1549],{},[565,1547,1548],{},"one share",", a choropleth of that percentage is clearer than any diagram.",[186,1551,1553],{"id":1552},"qgis-version-compatibility","QGIS version compatibility",[14,1555,1556,1557,1560,1561,1564,1565,1567],{},"The diagram API shown is stable across QGIS 3.34 LTR, 3.40 LTR and QGIS 4. On QGIS 4, enum members are scoped: ",[201,1558,1559],{},"QgsDiagramLayerSettings.Placement.OverPoint",". QGIS 3.40 added ",[201,1562,1563],{},"QgsStackedDiagram"," for combining several diagrams per feature; it does not change the pie API. ",[201,1566,1138],{}," has existed since 3.0.",[186,1569,1571],{"id":1570},"troubleshooting","Troubleshooting",[191,1573,1574,1583,1591,1600],{},[194,1575,1576,568,1579,1582],{},[565,1577,1578],{},"No pies appear.",[201,1580,1581],{},"settings.enabled"," was not set, layer settings were never assigned, or the scale is outside the visibility range.",[194,1584,1585,1588,1589,956],{},[565,1586,1587],{},"Pies are empty or missing on some features."," A category expression evaluated to NULL; wrap fields in ",[201,1590,710],{},[194,1592,1593,1596,1597,956],{},[565,1594,1595],{},"Large values dominate."," Size is scaled by diameter; set ",[201,1598,1599],{},"scaleByArea = True",[194,1601,1602,1605],{},[565,1603,1604],{},"Pies hide each other."," Enable collision handling or raise the minimum visibility scale.",[186,1607,1609],{"id":1608},"conclusion","Conclusion",[14,1611,1612,1613,1615,1616,1618],{},"Build pies with ",[201,1614,90],{}," and ",[201,1617,107],{},", use expressions to group detail into four or five categories with NULL-safe arithmetic, choose qualitative colours over a quiet base, scale area by a total when magnitude matters, manage collisions with priorities and scale limits, and switch to bars when precise comparison is the point.",[186,1620,1622],{"id":1621},"frequently-asked-questions","Frequently Asked Questions",[14,1624,1625,1628,1629,1632],{},[565,1626,1627],{},"Can pies be drawn in a print layout legend?","\nYes. Enable ",[201,1630,1631],{},"renderer.setAttributeLegend(True)"," and the categories appear in the layer's legend entry.",[14,1634,1635,1638,1639,1642],{},[565,1636,1637],{},"Can I rotate pies so the largest slice starts at the top?","\nSet ",[201,1640,1641],{},"settings.rotationOffset"," (degrees) on recent releases; slice order follows the category order.",[14,1644,1645,1648],{},[565,1646,1647],{},"Do diagrams work on line layers?","\nYes; they are placed along or over the line according to the placement setting.",[14,1650,1651,1654],{},[565,1652,1653],{},"Can diagrams be exported to SVG or PDF?","\nYes. They render as vector graphics in layout exports.",[186,1656,1658],{"id":1657},"related","Related",[191,1660,1661,1666,1671,1676,1682],{},[194,1662,1663,1665],{},[21,1664,24],{"href":23}," — the guide this recipe belongs to",[194,1667,1668],{},[21,1669,1670],{"href":1531},"Add Histogram Bar Diagrams in PyQGIS",[194,1672,1673],{},[21,1674,1675],{"href":1142},"Size Diagrams by Attribute in PyQGIS",[194,1677,1678],{},[21,1679,1681],{"href":1680},"\u002Fpyqgis-cartography-visualization\u002Fgraduated-categorized-renderers\u002Fcreate-proportional-symbol-map-pyqgis\u002F","Create a Proportional Symbol Map in PyQGIS",[194,1683,1684],{},[21,1685,1687],{"href":1686},"\u002Fpyqgis-cartography-visualization\u002Flabeling-and-annotations\u002Fcontrol-label-placement-and-collisions-pyqgis\u002F","Control Label Placement and Collisions in PyQGIS",[1689,1690,1691],"style",{},"html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sjoCn, html code.shiki .sjoCn{--shiki-default:#9AA79F}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":228,"searchDepth":251,"depth":251,"links":1693},[1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706],{"id":188,"depth":251,"text":189},{"id":217,"depth":251,"text":218},{"id":579,"depth":251,"text":580},{"id":770,"depth":251,"text":771},{"id":959,"depth":251,"text":960},{"id":1147,"depth":251,"text":1148},{"id":1336,"depth":251,"text":1337},{"id":1515,"depth":251,"text":1516},{"id":1552,"depth":251,"text":1553},{"id":1570,"depth":251,"text":1571},{"id":1608,"depth":251,"text":1609},{"id":1621,"depth":251,"text":1622},{"id":1657,"depth":251,"text":1658},"Draw a pie chart on every feature with QgsPieDiagram — choosing categories from fields or expressions, colours that match the rest of the map, fixed or scaled sizes, placement that avoids clutter, and the cases where a pie is the wrong chart.","md",{"slug":1710,"type":1711,"breadcrumb":1712,"datePublished":1713,"dateModified":1713},"add-pie-chart-diagrams-pyqgis","article","Add Pie Chart Diagrams","2026-10-02","\u002Fpyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002Fadd-pie-chart-diagrams-pyqgis",{"title":5,"description":1707},"pyqgis-cartography-visualization\u002Fdiagrams-and-charts-on-maps\u002Fadd-pie-chart-diagrams-pyqgis\u002Findex","U2XFysXvGHEsjAiiWeQ5z0hiDoUinCTcVeWY8hOKaOA",1790966252899]