Python 带有x值标签的seaborn条形图(无色调)

Python 带有x值标签的seaborn条形图(无色调),python,pandas,matplotlib,bar-chart,seaborn,Python,Pandas,Matplotlib,Bar Chart,Seaborn,我的dataframe包含两列,我想在条形图中绘制它们的值。像这样: import seaborn as sns # load sample data and drop all but two columns tips = sns.load_dataset("tips") tips= tips[["day", "total_bill"]] sns.set(style="whitegrid") ax = sns.barplot(x="day", y="total_bill", data=tip

我的dataframe包含两列,我想在条形图中绘制它们的值。像这样:

import seaborn as sns

# load sample data and drop all but two columns
tips = sns.load_dataset("tips")
tips= tips[["day", "total_bill"]]

sns.set(style="whitegrid")
ax = sns.barplot(x="day", y="total_bill", data=tips)

在这个条形图的顶部,我还想为每个x值添加一个带有标签的图例。Seaborn支持这一点,但据我所知,只有在指定色调参数时,它才起作用。图例中的每个标签都对应一个色调值

我可以创建一个带有x值说明的图例吗? 这可能是一个令人困惑的问题。我不想重命名轴的标签或沿轴的记号。相反,我希望有一个单独的图例和其他解释。我的栏给了我一些很好的空间来放置这个图例,解释太长,无法将它们作为记号。

这就是您想要的:

sns.set(style="whitegrid")
ax = sns.barplot(x="day", y="total_bill", data=tips)

ax.legend(ax.patches, ['1','2','3','Something that I can\'t say'], loc=[1.01,0.5])
输出: