pizza_chart


This function creates a pie chart.

pizza_chart(**kwargs)

Input variables

Name Description Type
plot_setup

Setup chart Dictionary with the following keys:

  • name: Path + name of the figure
  • width: Figure width in SI units
  • height: Figure height in SI units
  • colors: List of colors for the pie slices
  • size_legend: Font size of the legend
  • dots_per_inch: The resolution in dots per inch
  • extension: File extension
Dictionary
dataset

Dataset to plot

List or array

Output variables

Name Description Type
None The function displays the plot on the screen and saves it to the local folder of the .ipynb or .py None

Example 1

Use the pizza_chart function to perform a task.

# Data
df = pd.DataFrame({'category': ['Wheat', 'Rice', 'Bean', 'Potato', 'Canola'],
                   'values': [100, 250, 200, 120, 80]
                  })

# Chart setup
chart_config = {
    'name': 'figure1-5-1',
    'width': 15,
    'height': 15,
    'text color': 'w',
    'text font size': 12,
    'size legend': 10,
    'colors': ['r', 'g', 'b', 'black', 'y'],
    'dots per inch': 600,
    'extension': 'svg',
}

# Data statement 
data = {'dataset': df}

# Call function
pizza_chart(dataset=data, plot_setup=chart_config)

Figure 1. Week food consumption.

Notebook example