Data Visualisation Using Plot
Pandas Basics
2 min read
Published Sep 29 2025, updated Aug 17 2026
Guide Sections
Guide Comments
What is Pandas DataFrame.plot?
Pandas provides convenient built-in plotting, which is great for quick, exploratory visualisations. However, its plotting features are more limited compared to dedicated libraries like Matplotlib, Seaborn, or Plotly.
- Creates visualisations directly from DataFrames or Series.
df.plot(...)is just a wrapper around Matplotlib.- It creates a Matplotlib Axes object (a chart), plots the data, and returns it.
- Matplotlib itself is the underlying engine that actually draws the chart.
plt.show()is a Matplotlib command → renders the plot to screen/output.- Automatically uses column names for labels, legends, and axes.
Syntax
DataFrame.plot(kind="line", x=None, y=None, **kwargs)kind→ type of plot ("line","bar","hist", etc.).x→ column name to use as x-axis.y→ column(s) to plot on y-axis.**kwargs→ passed to Matplotlib (e.g.,figsize,title,xlabel,ylabel).
Since df.plot() always returns a Matplotlib Axes, you can keep customising (colors, labels, legends) with standard Matplotlib commands:
ax = df.plot(y="Sales", kind="line", color="red")ax.set_ylabel("Pounds")ax.set_title("Sales Trend")Plot Types (kind)
Kind | Description |
| Default, line plot |
| Vertical bar plot |
| Horizontal bar plot |
| Histogram |
| Box-and-whisker plot |
| Kernel density estimate |
| Area plot |
| Scatter plot (needs |
| Pie chart (works best on Series) |
Example data
Example DataFrame that is used in the chart examples below.
import pandas as pdimport matplotlib.pyplot as pltimport numpy as np# Sample datasetdf = pd.DataFrame({ "Product": ["A", "B", "C", "D", "E"], "Sales": [200, 120, 340, 300, 150], "Profit": [50, 20, 80, 70, 25], "Age": [23, 45, 36, 50, 29], "Height": [160, 170, 175, 180, 165], "Weight": [55, 70, 80, 90, 60]})Line Plot (default)
df.plot(y="Sales", kind="line", title="Line Plot - Sales")plt.show()
If you pass multiple y-columns, they’ll all be plotted together:
df.plot(y=["Sales", "Profit"], kind="line")Bar Plot
df.plot(x="Product", y="Sales", kind="bar", title="Bar Plot - Sales")plt.show()
Horizontal Bar Plot
df.plot(x="Product", y="Sales", kind="barh", title="Horizontal Bar Plot - Sales")plt.show()
Histogram
df["Age"].plot(kind="hist", bins=5, edgecolor="black", title="Histogram - Age")plt.show()
Box Plot
df[["Sales", "Profit"]].plot(kind="box", title="Box Plot - Sales vs Profit")plt.show()
KDE / Density Plot
df["Age"].plot(kind="kde", title="KDE Plot - Age")plt.show()Note, for KDE charts, you also need to install the SciPy module as it uses it under the hood : pip install scipy.

Area Plot
df.plot(y=["Sales", "Profit"], kind="area", alpha=0.5, title="Area Plot - Sales & Profit")plt.show()
Scatter Plot
df.plot(kind="scatter", x="Height", y="Weight", title="Scatter Plot - Height vs Weight")plt.show()
Pie Chart
df.set_index("Product")["Sales"].plot(kind="pie", autopct="%.1f%%", title="Pie Chart - Sales") # removes y-labelplt.ylabel("") plt.show()