0

i was wondering if anyone could help me with this. I want to change the colour of the bars on my barchart subject to a condition (in this case, if the uni rank is less than 50, i want to make the bar blue). Here's a snippet of the relevant code:

ukuni = pd.read_excel('2018-QS-World-University-Rankings-Top200.xlsx', sheet_name = "Sheet1", index_col=0)
ukunidf = ukuni[(ukuni.Location =='United Kingdom')]
ukunidf.plot.barh(y= "Overall Score", figsize=(10,10), color="red")
title("Top Uk Univerities in the QS-World-University Rankings")
xlabel("Overall Score")
ylabel("Institution Name")
show()

ive started an if statement as i think that is how i would have to go about doing this but im stumped beyond 'if "Rank" >50' as i'm unsure of how to change colour for a condition. Any help is much appreciated!

  • 1
    Hello and welcome to SO. This seems like a [duplicate](https://stackoverflow.com/questions/33476401/color-matplotlib-bar-chart-based-on-value) question. Does this help you? – StonedTensor Nov 10 '22 at 15:29

0 Answers0