Skip to content
Advertisement

How do you switch the colors of a bar chart in python matplotlib?

I’m trying to switch the colors of my bar charts so that they’re consistent throughout. In the plots below, I want to make it so JP_Sales is orange in both charts and NA_Sales is blue in both charts.

current plot

second plot

The code for the first chart is:

JavaScript

The code for the second chart is:

JavaScript

Advertisement

Answer

plot() has a color argument which takes a list in which you can specify the colors in the order in which the bars appear. So all you have to do is the following change for each plot:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement