This module provides a simple function to create a well-designed donut chart in Python. The function uses Plotly under the hood to create a chart that provides a quick and easy way to view the proportionality of data features.
A donut chart is a type of chart that displays data as a ring-shaped chart with a hole in the middle, similar to a pie chart. Some people find donut charts more visually appealing than pie charts (the "Forbidden Chart") as they can provide a clearer view of the data being displayed. However, it's important to use donut charts carefully and avoid using too many segments, as this can make the chart difficult to read and interpret.
As someone who loves donut charts, it's crucial to create a well-organized, visually appealing donut chart that presents the data in an easily understandable way. For instance, if you want to quickly grasp the proportion of different categories within a feature, you can simply use the module.
Data originally published in: Gorman KB, Williams TD, Fraser WR (2014). Ecological sexual dimorphism and environmental variability within a community of Antarctic penguins (genus Pygoscelis). PLoS ONE 9(3):e90081. Click here to view.
To use the module
- Download the
Donut.py
and save it in the same folder. - Import the
donutchart()
function and provide the necessary arguments.
import pandas as pd
from donutchart import donut
# Create a sample dataset
data = pd.Series(['Dog', 'Dog', 'Cat', 'Bunny','Bunny','Bunny', 'Cat', 'Dog', 'Dog', 'Dog', 'Dog', 'Bunny', 'Dog', 'Dog'])
title = 'Distribution of Dog, Cat and Bunny'
# Create the donut chart
donut(data=data, title=title, legend = False)
The donut()
function takes the following arguments:
data
: The data to be charted. This should be in a pandas Series format.title
: The title of the chart.hole
: The size of the hole in the middle of the chart. This ranges from 0 to 1 and defaults to 0.5.legend
: Whether to include a legend. Defaults to True.
⚠️ Note that the donut() function is not suitable for use with data that has more than three categories.
This module is licensed under the MIT License. Click the LICENSE for more details.