How to Change the Color of a Graph Plot in Matplotlib with Python? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 2 Likes Like Report Prerequisite: Matplotlib Python offers a wide range of libraries for plotting graphs and Matplotlib is one of them. Matplotlib is simple and easy to use a library that is used to create quality graphs. The pyplot library of matplotlib comprises commands and methods that makes matplotlib work like matlab. The pyplot module is used to set the graph labels, type of chart and the color of the chart. The following methods are used for the creation of graph and corresponding color change of the graph. Syntax: matplotlib.pyplot.bar(x, height, width, bottom, align, **kwargs) Parameter: x : sequence of scalers along the x axisheight : sequence of scaler determining the height of bar ie y-axiswidth : width of each barbottom : Used to specify the starting value along the Y axis.(Optional)align : alignment of the bar**kwargs : other parameters one of which is color which obviously specifies the color of the graph. Return Value: Returns the graph plotted from the specified columns of the dataset. In this article, we are using a dataset downloaded from kaggel.com for the examples given below. The dataset used represent countries against the number of confirmed covid-19 cases. The dataset can be downloaded from the given link: Dataset Used: Corona virus report Example 1: Python3 # import packages import pandas as pd import matplotlib import matplotlib.pyplot as plt # import dataset df = pd.read_csv('country_wise_latest.csv') # select required columns country = df['Country/Region'].head(10) confirmed = df['Confirmed'].head(10) # plotting graph plt.xlabel('Country') plt.ylabel('Confirmed Cases') plt.bar(country, confirmed, color='green', width=0.4) # display plot plt.show() Output Example 2: Python3 # import packages import pandas as pd import matplotlib import matplotlib.pyplot as plt # import dataset df = pd.read_csv('country_wise_latest.csv') # select required data country = df['Country/Region'].head(20) confirmed = df['Active'].head(20) # plot graph plt.xlabel('Country') plt.ylabel('Active Cases') plt.bar(country, confirmed, color='maroon', width=0.4) # display plot plt.show() Output Create Quiz Comment S Shreyasi_Chakraborty Follow 2 Improve S Shreyasi_Chakraborty Follow 2 Improve Article Tags : Technical Scripter Python Technical Scripter 2020 Python-matplotlib Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 3 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 3 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 3 min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 6 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Build a REST API using Flask - Python 3 min read Building a Simple API with Django REST Framework 3 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like