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 Point to Comma in Matplotlib Graphics in Python We are given a Matplotlib Graph and our task is to change the point to a comma in Matplotlib Graphics such that there is only a comma in the whole graph instead of a point. In this article, we will see how we can change the point to comma in Matplotlib Graphics in Python. Change Point to Comma in Ma 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 How to create a Scatter Plot with several colors in Matplotlib? Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. Matplotlib can be used in Python scripts, the Python and IPython shell, web application servers, and various graphical user interface toolkits like Tkinter, awxPython, etc. In this article, we w 3 min read How to Adjust the Position of a Matplotlib Colorbar? A colorbar is a bar that has various colors in it and is placed along the sides of the Matplotlib chart. It is the legend for colors shown in the chart. By default, the position of the Matplotlib color bar is on the right side. The position of the Matplotlib color bar can be changed according to our 5 min read How to Add Axes to a Figure in Matplotlib with Python? Matplotlib is a library in Python used to create figures and provide tools for customizing it. It allows plotting different types of data, geometrical figures. In this article, we will see how to add axes to a figure in matplotlib. We can add axes to a figure in matplotlib by passing a list argument 2 min read How to reverse a Colormap using Matplotlib in Python? Prerequisites: Matplotlib Matplotlib has many built-in Colormaps. Colormaps are nothing but the dictionary which maps the integer data/numbers into colors. Colormaps are used to differentiate or distinguish the data in a particular plot. The reason to use the colormaps is that it is easier for human 6 min read Like