我想知道有没有可能将堆叠的条形图与海运猫图结合起来。例如:
import seaborn as sns
exercise = sns.load_dataset("exercise")
plot = exercise.groupby(['diet'])['kind'].value_counts(normalize=True).mul(100).reset_index(name='percentage%')
g = sns.catplot(x="diet", y="percentage%", hue="kind", data=plot, kind='bar')

我想堆叠kind,但似乎catplot不接受'stacked‘参数。
发布于 2021-03-22 19:39:56
你不能使用sns.barplot来做到这一点,我认为你能得到的最接近的方法是使用sns.histplot:
import seaborn as sns
exercise = sns.load_dataset("exercise")
plot = exercise.groupby(['diet'])['kind'].value_counts(normalize=True).mul(100).reset_index(name='percentage')
g = sns.histplot(x = 'diet' , hue = 'kind',weights= 'percentage',
multiple = 'stack',data=plot,shrink = 0.7)

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