【发布时间】:2020-03-10 16:01:22
【问题描述】:
所以我有这个水平条形图,我想用其他颜色突出显示某些标签(或关键字)。 这是我的水平条形图:
我想让关键字“自然”和“全景”为红色。我试过这段代码,但它不起作用:
f, ax = plt.subplots(figsize=(15,15))
plt.autoscale(enable=True, axis='y', tight=True) # tight layout
plt.barh(df['keywords'], df['number']) # base barplot with blue color
plt.barh(df[df['keywords']=='nature'], df['number'], color='red') # overlay barplot with red color
plt.barh(df[df['keywords']=='panorama'], df['number'], color='red') # overlay barplot with red color
ax.tick_params(labelsize=18)
plt.title('Difference average of cluster 3')
【问题讨论】:
-
实际上并非如此。因为它占据了标签的位置,而我想根据关键字突出显示标签。
标签: python matplotlib