Created
September 18, 2020 16:55
-
-
Save fuji246/b962abf04daf6ac73a60edbc87161b7f to your computer and use it in GitHub Desktop.
stack bar plot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import OrderedDict, Counter | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib | |
june_data = { | |
'joining_or_others': 44, | |
'video_delay': 29, | |
'meeting_dropped': 25, | |
'ui_ux_design': 19, | |
'audio_receive_fail': 17, | |
'audio_receive_bad': 17, | |
'video_receive_bad': 17, | |
'application_crash_or_freeze': 12, | |
'network': 6, | |
'video_receive_stop': 6, | |
'video_receive_fail': 6, | |
'streaming': 4, | |
'camera': 4, | |
'screen_receive_bad': 4, | |
'audio_device_fail': 3, | |
'screen_receive_delay': 3, | |
'screen_receive_fail': 2, | |
'ice_fail': 2, | |
'screen_send_fail': 1, | |
'annotation': 1, | |
'video_receive_choppy': 1, | |
'video_connect_fail': 1, | |
'audio_connect_fail': 1, | |
'virtual_background': 1, | |
'cpu': 1 | |
} | |
july_data = { | |
'joining_or_others': 76, | |
'audio_receive_bad': 33, | |
'video_receive_bad': 22, | |
'ui_ux_design': 22, | |
'meeting_dropped': 20, | |
'video_delay': 20, | |
'audio_receive_fail': 14, | |
'network': 12, | |
'application_crash_or_freeze': 11, | |
'video_receive_fail': 8, | |
'screen_receive_bad': 8, | |
'streaming': 7, | |
'video_receive_stop': 7, | |
'virtual_background': 5, | |
'audio_connect_fail': 4, | |
'audio_device_fail': 4, | |
'camera': 4, | |
'screen_receive_fail': 3, | |
'cpu': 3, | |
'screen_receive_delay': 3, | |
'ice_fail': 2, | |
'video_receive_choppy': 2, | |
'audio_send_fail': 1, | |
'screen_send_fail': 0, | |
'annotation': 0, | |
'video_connect_fail': 0, | |
} | |
aug_data = { | |
'joining_or_others': 76, | |
'video_delay': 28, | |
'meeting_dropped': 21, | |
'audio_receive_bad': 15, | |
'video_receive_bad': 14, | |
'ui_ux_design': 13, | |
'audio_receive_fail': 12, | |
'application_crash_or_freeze': 10, | |
'screen_receive_bad': 9, | |
'virtual_background': 8, | |
'video_receive_stop': 8, | |
'streaming': 7, | |
'network': 7, | |
'screen_receive_delay': 6, | |
'camera': 5, | |
'cpu': 3, | |
'video_receive_choppy': 3, | |
'screen_receive_fail': 2, | |
'ice_fail': 2, | |
'video_receive_fail': 2, | |
'audio_device_fail': 2, | |
'audio_connect_fail': 1, | |
'video_connect_fail': 1, | |
'recording': 1, | |
'annotation': 1, | |
'screen_send_fail': 0 | |
} | |
data = OrderedDict([ | |
('Jun', june_data), | |
('Jul', july_data), | |
('Aug', aug_data) | |
]) | |
print(data) | |
def get_dataframe(): | |
rows = [] | |
for month, stats in data.items(): | |
c = dict(Counter(stats).most_common(10)) | |
for label, count in c.items(): | |
rows.append((month, label, count)) | |
headers = ['Month', 'Category', 'Count'] | |
df = pd.DataFrame(rows, columns=headers) | |
return df | |
df = get_dataframe() | |
pivot_df = df.pivot(index='Month', columns='Category', values='Count') | |
print(pivot_df) | |
pivot_df = pivot_df.reindex(data.keys()) | |
fig, ax = plt.subplots(figsize=(10,7)) | |
plt.title('Bandwidth/Connectivity/Latency Trend (top10)') | |
pivot_df.plot.bar(ax=ax, rot=0, stacked=True) | |
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5)) | |
fig.subplots_adjust(right=0.7) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment