How to Change the Color of a Graph Plot in Matplotlib with Python? Last Updated : 23 May, 2024 Comments Improve Suggest changes Like Article 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 Comment More infoAdvertise with us Next Article How to Change the Color of a Graph Plot in Matplotlib with Python? S Shreyasi_Chakraborty Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2020 Python-matplotlib Practice Tags : python Similar Reads How to Change the Line Width of a Graph Plot in Matplotlib with Python? Prerequisite : Matplotlib In this article we will learn how to Change the Line Width of a Graph Plot in Matplotlib with Python. For that one must be familiar with the given concepts: Matplotlib : Matplotlib is a tremendous visualization library in Python for 2D plots of arrays. Matplotlib may be a 2 min read How to Change the Transparency of a Graph Plot in Matplotlib with Python? Changing transparency in Matplotlib plots enhances visual clarity, especially when data overlaps. Transparency is controlled using a value between 0 (fully transparent) and 1 (fully opaque). This setting can be applied to elements like lines, bars, scatter points and filled areas either during plot 3 min read How to Add Markers to a Graph Plot in Matplotlib with Python? In this article, we will learn how to add markers to a Graph Plot in Matplotlib with Python. For that just see some concepts that we will use in our work. Graph Plot: A plot is a graphical technique for representing a data set, usually as a graph showing the relationship between two or more variable 2 min read How to Change the Color of a Graph Plot using pygal? Prerequisites: pygal Pygal is a graphics and user interface library for Python that provides functionality commonly required in designing and science applications. In this article, we will see how we can change chart color in the Pygal module. While making a chart it is important for us to adjust co 2 min read How to generate a random color for a Matplotlib plot in Python? Handling huge dataset requires libraries and methods that can be used to store, analyze and manipulate the datasets. Python is a popular choice when it comes to data science and analytics. Data scientists prefer Python due to its wide library support that contains functions which can be used to work 3 min read Like