遇到一个问题,如何使用字典重命名lineplot中现有的xticklabels?部分代码:
zodiac_order = ['Aries', 'Taurus', 'Gemini', 'Cancer', 'Leo', 'Virgo', 'Libra', 'Scorpio','Sagittarius', 'Capricorn', 'Aquarius', 'Pisces'] # df_one here is DataFrame
zodiac_counts = df_one["Zodiac"].value_counts()
plt.figure(figsize=(14,6))
zodiac = sns.lineplot(data=zodiac_counts, marker='o', color='mediumvioletred')
zodiac.yaxis.grid(True)
[plt.gca().spines[loc].set_visible(False) for loc in ['top', 'right']]
zodiac.set(xticklabels=zodiac_order) # made list to be in order according to real list of zodiacs
我想改变xticks 标签的语言,所以有字典
zodiacs_lt = {'Aries': 'Avinas',
'Taurus': 'Jautis',
'Gemini': 'Dvyniai',
'Cancer': 'Vėžys',
'Leo': 'Liūtas',
'Virgo': 'Mergelė',
'Libra': 'Svarstyklės',
'Scorpio': 'Skorpionas',
'Sagittarius': 'Šaulys',
'Capricorn': 'Ožiaragis',
'Aquarius': 'Vandenis',
'Pisces': 'Žuvys'
}