How to plot a Pandas Dataframe with Matplotlib? Last Updated : 09 Apr, 2025 Comments Improve Suggest changes Like Article Like Report We have a Pandas DataFrame and now we want to visualize it using Matplotlib for data visualization to understand trends, patterns and relationships in the data. In this article we will explore different ways to plot a Pandas DataFrame using Matplotlib's various charts. Before we start, ensure you have the necessary libraries using:pip install pandas matplotlibTypes of Data Visualizations in MatplotlibMatplotlib offers a wide range of visualization techniques that can be used for different data types and analysis. Choosing the right type of plot is essential for effectively conveying data insights.1. Bar PlotBar Plot is useful for comparing values across different categories and comparing Categorical Data. It displays rectangular bars where the height corresponds to the magnitude of the data. Python import pandas import matplotlib data = {'Category': ['A', 'B', 'C', 'D'], 'Values': [20, 34, 30, 35]} df = pd.DataFrame(data) plt.bar(df['Category'], df['Values'], color='skyblue') plt.xlabel("Category") plt.ylabel("Values") plt.title("Bar Chart Example") plt.show() Output:Bar Plot2. HistogramA histogram groups numerical data into intervals (bins) to show frequency distributions. It helps in understanding data distribution and spotting trends and is widely used for continuous data. Python import pandas import matplotlib df = pd.DataFrame({'Values': [12, 23, 45, 36, 56, 78, 89, 95, 110, 130]}) plt.hist(df['Values'], bins=5, color='lightcoral', edgecolor='black') plt.xlabel("Value Range") plt.ylabel("Frequency") plt.title("Histogram Example") plt.show() Output:Histogram3. Pie ChartA pie chart is used to display categorical data as proportions of a whole. Each slice represents a percentage of the dataset. Python import pandas import matplotlib df = pd.DataFrame({'Category': ['A', 'B', 'C'], 'Values': [30, 50, 20]}) plt.pie(df['Values'], labels=df['Category'], autopct='%1.1f%%', colors=['gold', 'lightblue', 'pink']) plt.title("Pie Chart Example") plt.show() Output:Pie Chart4. Scatter PlotA scatter plot visualizes the relationship between two numerical variables helping us to identify correlations and data patterns. Python import pandas import matplotlib df = pd.DataFrame({'X': [1, 2, 3, 4, 5], 'Y': [2, 4, 1, 8, 7]}) plt.scatter(df['X'], df['Y'], color='green', marker='o') plt.xlabel("X-axis") plt.ylabel("Y-axis") plt.title("Scatter Plot Example") plt.show() Output:Scatter Plot5. Line ChartA line chart is ideal for analyzing trends and patterns in time-series or sequential data by connecting data points with a continuous line. Python import pandas import matplotlib df = pd.DataFrame({'Month': ['Jan', 'Feb', 'Mar', 'Apr', 'May'], 'Sales': [200, 250, 300, 280, 350]}) plt.plot(df['Month'], df['Sales'], marker='o', linestyle='-', color='blue') plt.xlabel("Month") plt.ylabel("Sales") plt.title("Line Chart Example") plt.grid() plt.show() Output:Line ChartIn this article we explored various techniques to visualize data from a Pandas DataFrame using Matplotlib. From bar charts for categorical comparisons to histograms for distribution analysis and scatter plots for identifying relationships each visualization serves a unique purpose. Comment More infoAdvertise with us Next Article How to plot a Pandas Dataframe with Matplotlib? d2anubis Follow Improve Article Tags : Technical Scripter Python Technical Scripter 2020 Python-pandas Python pandas-dataFrame Python-matplotlib +2 More Practice Tags : python Similar Reads How to Create a Table with Matplotlib? In this article, we will discuss how to create a table with Matplotlib in Python. Method 1: Create a Table using matplotlib.plyplot.table() function In this example, we create a database of average scores of subjects for 5 consecutive years. We import packages and plotline plots for each consecutive 3 min read How to Create a Table with Matplotlib? In this article, we will discuss how to create a table with Matplotlib in Python. Method 1: Create a Table using matplotlib.plyplot.table() function In this example, we create a database of average scores of subjects for 5 consecutive years. We import packages and plotline plots for each consecutive 3 min read How to Create a Table with Matplotlib? In this article, we will discuss how to create a table with Matplotlib in Python. Method 1: Create a Table using matplotlib.plyplot.table() function In this example, we create a database of average scores of subjects for 5 consecutive years. We import packages and plotline plots for each consecutive 3 min read How to Create Subplots in Matplotlib with Python? Matplotlib is a widely used data visualization library in Python that provides powerful tools for creating a variety of plots. One of the most useful features of Matplotlib is its ability to create multiple subplots within a single figure using the plt.subplots() method. This allows users to display 6 min read How to Create Subplots in Matplotlib with Python? Matplotlib is a widely used data visualization library in Python that provides powerful tools for creating a variety of plots. One of the most useful features of Matplotlib is its ability to create multiple subplots within a single figure using the plt.subplots() method. This allows users to display 6 min read How to Create Subplots in Matplotlib with Python? Matplotlib is a widely used data visualization library in Python that provides powerful tools for creating a variety of plots. One of the most useful features of Matplotlib is its ability to create multiple subplots within a single figure using the plt.subplots() method. This allows users to display 6 min read How to plot data from a text file using Matplotlib? Perquisites: Matplotlib, NumPy In this article, we will see how to load data files for Matplotlib. Matplotlib is a 2D Python library used for Date Visualization. We can plot different types of graphs using the same data like: Bar GraphLine GraphScatter GraphHistogram Graph and many. In this article, 3 min read How to plot data from a text file using Matplotlib? Perquisites: Matplotlib, NumPy In this article, we will see how to load data files for Matplotlib. Matplotlib is a 2D Python library used for Date Visualization. We can plot different types of graphs using the same data like: Bar GraphLine GraphScatter GraphHistogram Graph and many. In this article, 3 min read How to plot data from a text file using Matplotlib? Perquisites: Matplotlib, NumPy In this article, we will see how to load data files for Matplotlib. Matplotlib is a 2D Python library used for Date Visualization. We can plot different types of graphs using the same data like: Bar GraphLine GraphScatter GraphHistogram Graph and many. In this article, 3 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 Like