Currently the color of the bar are the same. How can I change the color of the bar with the highest value?
df.groupby("Position")["Salary"].mean() #Plot bar graph ax = df.groupby("Position")["Salary"].mean().plot(kind="bar",width = 0.8, color='darkblue') plt.xlabel("Position",fontsize=12) plt.ylabel("Salary",fontsize=12) plt.title("Wages for different job functions", fontweight='bold', fontsize=14) plt.show()
Advertisement
Answer
Try:
s = df.groupby("Position")["Salary"].mean() s.plot.bar(color=np.where(s==s.max(), 'r','b'))
Output: