我想知道是否有可能在MatPlotLib的利克特标尺中包括每个亚组的百分比?任何帮助都将不胜感激!
Python代码:
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)

发布于 2022-02-04 15:00:48
@约翰回答了我的问题-
您需要更新到最新的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)

https://stackoverflow.com/questions/70975856
复制相似问题