I'm currently analyzing a WhatsApp chat history. One thing I'm interested in is the time when the two people communicated. I thought this is a perfect use case for a radar chart (aka spider chart, star chart). So here is one example:
I find this super hard to read. In contrast, have a look at the following bar chart with exactly the same information:
Here it is way easier for me to see patterns:
- 0 - 5: No activity (sleeping)
- 6 - 9: A morning peak (messages after waking up)
- 10 - 16: Little activity (work times)
- 17 - 19: Increased activity (work is done)
- 20 - 21: High activity
- 22 - 23: Sinking activity (going to bed)
Question
What are typical use-cases for radar charts? Are there specific requirements on the data? When are they better than bar charts? How should I set the ticks for radar charts?
Before people starting to close-vote: I could imagine very well that there are similar studies like for color maps - how many errors are done in analysis? How fast can people pick up main insights?
Example code
In case you want to improve the existing visualizations:
# core modules
from math import pi
# 3rd party modules
import matplotlib.pyplot as plt
import pandas as pd
def main():
df = pd.DataFrame({'date': [209, 13, 1, 2, 1, 25, 809, 3571, 1952, 1448, 942, 1007, 1531, 1132, 981, 864, 975, 2502, 2786, 2717, 3985, 4991, 2872, 761]},
index=[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23])
create_bar_chart(df)
create_radar_chart(df)
def create_bar_chart(df, output_path='bar_chart.png'):
df.plot(kind='bar')
plt.savefig(output_path)
def create_radar_chart(df, output_path='radar_chart.png'):
"""
Create a radar chart.
Parameters
----------
df : pandas.DataFrame
Has a column 'date'
"""
values = df['date'].tolist()
df = df.T.reset_index(drop=True)
df.insert(0, 'group', 'A')
# number of variable
categories = list(df)[1:]
N = len(categories)
# What will be the angle of each axis in the plot?
# (we divide the plot / number of variable)
angles = [n / float(N) * 2 * pi for n in range(N)]
angles += angles[:1]
# Initialise the spider plot
ax = plt.subplot(111, polar=True)
# Draw one axe per variable + add labels labels yet
plt.xticks(angles[:-1], categories, color='grey', size=8)
# We are going to plot the first line of the data frame.
# But we need to repeat the first value to close the circular graph:
values = df.loc[0].drop('group').values.flatten().tolist()
values += values[:1]
values
# Plot data
ax.plot(angles, values, linewidth=1, linestyle='solid')
# Fill area
ax.fill(angles, values, 'b', alpha=0.1)
plt.savefig(output_path)
if __name__ == '__main__':
main()


