How to plot a Pandas Dataframe with Matplotlib? Last Updated : 09 Apr, 2025 Summarize Comments Improve Suggest changes Share 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? D 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 Python Tutorial - Learn Python Programming Language Python is one of the most popular programming languages. Itâs simple to use, packed with features and supported by a wide range of libraries and frameworks. Its clean syntax makes it beginner-friendly. It'sA high-level language, used in web development, data science, automation, AI and more.Known fo 10 min read Python Interview Questions and Answers Python is the most used language in top companies such as Intel, IBM, NASA, Pixar, Netflix, Facebook, JP Morgan Chase, Spotify and many more because of its simplicity and powerful libraries. To crack their Online Assessment and Interview Rounds as a Python developer, we need to master important Pyth 15+ min read Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co 11 min read Python OOPs Concepts Object Oriented Programming is a fundamental concept in Python, empowering developers to build modular, maintainable, and scalable applications. By understanding the core OOP principles (classes, objects, inheritance, encapsulation, polymorphism, and abstraction), programmers can leverage the full p 11 min read Python Projects - Beginner to Advanced Python is one of the most popular programming languages due to its simplicity, versatility, and supportive community. Whether youâre a beginner eager to learn the basics or an experienced programmer looking to challenge your skills, there are countless Python projects to help you grow.Hereâs a list 10 min read Python Exercise with Practice Questions and Solutions Python Exercise for Beginner: Practice makes perfect in everything, and this is especially true when learning Python. If you're a beginner, regularly practicing Python exercises will build your confidence and sharpen your skills. To help you improve, try these Python exercises with solutions to test 9 min read Python Programs Practice with Python program examples is always a good choice to scale up your logical understanding and programming skills and this article will provide you with the best sets of Python code examples.The below Python section contains a wide collection of Python programming examples. These Python co 11 min read Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance 10 min read Python Introduction Python was created by Guido van Rossum in 1991 and further developed by the Python Software Foundation. It was designed with focus on code readability and its syntax allows us to express concepts in fewer lines of code.Key Features of PythonPythonâs simple and readable syntax makes it beginner-frien 3 min read Python Data Types Python Data types are the classification or categorization of data items. It represents the kind of value that tells what operations can be performed on a particular data. Since everything is an object in Python programming, Python data types are classes and variables are instances (objects) of thes 9 min read Like