class visigoth.charts.pie.Pie(data, value=0, colour=1, width=768, height=768, palette=None, stroke='black', stroke_width=2, doughnut=False, labelfn=<function Pie.<lambda>>, font_height=20, text_attributes={})

Create a Hierarchical Pie/Doughnut Chart


data (dict) – A relational data set (for example, list of dicts/lists/tuples describing each row)

Keyword Arguments:
  • value (str or int) – Identify the column to specify the value (use count if not specified)
  • colour (str or int) – Identify the column to define the sector colour (provide a list to create a multi-level pie chart)
  • width (int) – the width of the plot in pixels
  • height (int) – the height of the plot in pixels
  • palette (list) – a DiscretePalette object
  • stroke (str) – stroke color for pie sectors
  • stroke_width (int) – stroke width for pie sectors
  • doughnut (boolean) – set True to draw as a doughnut rather than a pie chart
  • labelfn (lambda) – function to compute a label string, given a category and numeric value
  • font_height (int) – sets the maximum font height used to display labels
  • text_attributes (dict) – attributes to apply to text labels


(Link to open example in new tab):

Source Code (Link to Github):

# -*- coding: utf-8 -*-

from visigoth.diagram import Diagram
from visigoth.charts import Pie
from visigoth.utils.colour import DiscretePalette
from visigoth.common import Legend

palette = DiscretePalette()
data = [("A",10),("B",4),("D",12),("D.2",3),("D.3",5)]

d = Diagram()

pie = Pie(data,colour=0,value=1,width=400, height=400, palette=palette, doughnut=True)
legend = Legend(palette,400,legend_columns=2)
html = d.draw(format="html")

f = open("example.html", "w")