'Adding percentages to subgroups of each group likert-scale Python
I am wondering is it possible to include the percentage breakdown of each subgroup in the bars of a likert-scale with MatPlotLib? Any help would be greatly appreciated!
Python Code:
from numpy.core import numeric
import plot_likert
import pandas as pd
# define my selections
myscale1 = \
['Very unlikely',
'Unlikely',
'Neutral',
'Likely',
'Very likely']
# create a likert plot
ax1 = plot_likert.plot_likert(GenZ, myscale1, plot_percentage=True, figsize=(15,15), colors=plot_likert.colors.likert5)
ax1.set_title(('Casually watch big matches'), fontsize=30)
ax1.set_ylabel('Football/Soccer Moments',fontdict={'fontsize':28})
ax1.tick_params(axis='y', labelsize=20)
ax1.legend(loc="upper middle", ncol=5)

Solution 1:[1]
@JohanC answered my question -
you need to update to the most recent MatPlotLib
import plot_likert
import pandas as pd
# define my selections
myscale1 = \
['Strongly disagree',
'Somewhat disagree',
'Neither agree nor disagree',
'Somewhat agree',
'Strongly agree']
# create a likert plot
ax1 = plot_likert.plot_likert(agree_statements, myscale1, plot_percentage=True, figsize=(20,20), colors=plot_likert.colors.likert5)
ax1.set_title(('Casually watch big matches (21-34 year old)'), fontsize=30)
ax1.set_ylabel('Football/Soccer Moments',fontdict={'fontsize':28})
ax1.set_xlabel('% Breakdown',fontdict={'fontsize':28})
ax1.tick_params(axis='y', labelsize= 15)
ax1.tick_params(axis='x', labelsize= 10)
for bars, color in zip(ax1.containers[1:], ['white'] + ['black'] * 2 + ['white'] * 2):
ax1.bar_label(bars, label_type='center', fmt='%.1f %%', color=color, fontsize=15)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Donnchadh O Sullivan |

