{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Basics of using generalized code to make a donut plot with subgroups\n", "\n", "This just covers the basics to remake [the example from The Python Graph Gallery](https://python-graph-gallery.com/163-donut-plot-with-subgroups/) shown below. Let's make something very similar to this:\n", "\n", "\n", "![plot example](https://python-graph-gallery.com/wp-content/uploads/163_Double_Donut_Chart.png)\n", "\n", "\n", "A more full-featured script that makes a similar plot from the same data **without further need for coding** that allows you to plug in your own data input is demonstrated in [this notebook](index.ipynb). Click back to [that page](index.ipynb) if you want the fastest route to a donut plot that you can easily customize. Or go to the following in the series if you want related full-featured scripts and aren't interesting in the coding behind it.\n", "\n", "- [Demonstrate a full-featured script that plots a summary for the subgroups in addition to the donut plot with subgroups](demo_summary_subgroups.ipynb)\n", "- [Demonstrate a full-featured script that plots a summary for binary data in addition to the donut plot with the binary group broken down by a group](demo_summary_binary.ipynb)\n", "\n", "----" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Preparation" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A dataframe will be used for input data. The following code will define it." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | group | \n", "subgroup | \n", "sub-subgroup | \n", "
---|---|---|---|
0 | \n", "A | \n", "1 | \n", "frizzled | \n", "
1 | \n", "A | \n", "1 | \n", "lethargic | \n", "
2 | \n", "A | \n", "1 | \n", "polythene | \n", "
3 | \n", "A | \n", "1 | \n", "epic | \n", "
4 | \n", "A | \n", "2 | \n", "frizzled | \n", "