我有一个数据集,该数据集包含1750年至2013年世界上每个国家及其各自的每日平均温度。在其他可视化中,我正在尝试制作一个由这些国家的平均温度组成的海图,显示哪些是一切正常,除了我的酒吧按字母顺序排列(阿富汗,非洲等)并且不按温度顺序排列(迪吉布提是最热门)。
meantemp = df.groupby('Country').AverageTemperature.mean() #average temperatures per country
meantemp.sort_values(ascending = False) #this sorts the values in descending order, the hottest country being the first
f, ax = plt.subplots(figsize=(10, 45))
sns.barplot(x=meantemp, y=meantemp.index, palette=sns.color_palette("RdBu_r", len(meantemp)))
texts = ax.set(ylabel="", xlabel="Temperature (Celsius)", title="Average temperature in each country")
现在,我仅使用变量“ meantemp”,因为它的索引由国家组成,并且其列由各自的平均温度组成。我希望条形图可以按数字而不是索引排序。我该怎么解决?
代码的实际输出在这里