Home Artificial Intelligence Three Charts to Represent a Percentage You May Not Know Setting Up the Scenario Donut Chart

Three Charts to Represent a Percentage You May Not Know Setting Up the Scenario Donut Chart

0
Three Charts to Represent a Percentage You May Not Know
Setting Up the Scenario
Donut Chart

Data Visualization, Python

A ready-to-run tutorial in Python Altair to construct charts to represent a percentage

Towards Data Science
Photo by Markus Winkler on Unsplash

Representing a percentage visually may engage the audience more and help them higher understand the information. There are other ways to represent a percentage visually. Essentially the most straightforward strategy is a Big Number (BAN), as shown within the figure below.

Image by Writer

Along with BAN, there are other ways to represent a percentage visually. In this text, we’ll deal with three strategies:

  • Donut Chart
  • 100% Stacked Chart
  • Waffle Chart.

We are going to use Python Altair to indicate methods to construct each strategy. The Vega-Altair library (Altair, for brief) is a declarative Python library for statistical visualization based on the Vega and Vega-Lite visualization grammars. For more details on methods to start with Altair, you possibly can read the official Python Altair documentation.

To point out how each form of chart works, we’ll represent the next percentage: 70%. To represent this value, you need to use the next Pandas DataFrame:

data = {
'percentage': [0.7,0.3],
'label' : ['70%','30%'],
'color' : ['#81c01e','lightgray']
}

df = pd.DataFrame(data)

The DataFrame must contain two values: the share (70%) and its complementary value (30%). As well as, we set the colours related to each slice: #81c01e (a form of green) for our worth, and light-weight gray for the opposite.

Let’s start representing this DataFrame through a donut chart.

A donut chart is a circular chart displaying data in a hoop shape. It is comparable to the pie chart but with a hole in the middle, making a visual representation of percentages of various categories.

LEAVE A REPLY

Please enter your comment!
Please enter your name here