To plot a pandas DataFrame, call df.plot(). It draws one line per numeric column against the index, using Matplotlib. Pick another chart with kind= (df.plot(kind="bar")) or the matching method (df.plot.bar()). It returns a Matplotlib Axes, so everything you know about Matplotlib still works on the result. This page links the pandas plotting tutorials on this site, grouped by task, and the examples are written for pandas 3.0.

Quick Example
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
rng = np.random.default_rng(31)
months = pd.period_range("2025-01", periods=12, freq="M")
season = np.cos(2 * np.pi * np.arange(12) / 12)
sales = pd.DataFrame({
"Latte": 1800 + 300 * season + rng.normal(0, 60, 12),
"Cold brew": 900 - 550 * season + rng.normal(0, 60, 12),
"Tea": 700 + 150 * season + rng.normal(0, 40, 12),
}, index=months).round()
ax = sales.plot(figsize=(8, 4.5), marker="o", ylim=(0, 2600),
title="Cups sold per month", ylabel="Cups")
ax.legend(loc="upper left", ncols=3)
plt.show()

Each column becomes a line and the index becomes the x-axis. The index here is a PeriodIndex of months, which works for every kind; see the errors table below for a bar chart bug with dates in pandas 3.0.0 to 3.0.5. figsize, ylim, title, and ylabel go straight to df.plot(); for anything else, use the returned ax.
Which df.plot kind should I use?
df.plot(kind=...) and df.plot.<kind>() are the same thing. These six panels plot the same sales DataFrame. The bar panel uses month names as a text index, because bar charts label every row of the index, and how pandas labels dates on bars has changed between 3.0 and 3.1:
kinds = ["line", "bar", "area", "hist", "box", "kde"]
by_month = sales.set_axis(sales.index.strftime("%b")) # text labels for the bars
fig, axs = plt.subplots(2, 3, figsize=(13, 7), layout="constrained")
for ax, kind in zip(axs.flat, kinds):
data = by_month if kind == "bar" else sales
options = {"alpha": 0.6} if kind == "hist" else {}
data.plot(kind=kind, ax=ax, legend=False, rot=0, **options)
ax.set_title(f'kind="{kind}"', family="monospace")
ax.set_xlabel("")
fig.legend(*axs[0, 0].get_legend_handles_labels(), loc="outside upper center", ncols=3)
plt.show()

| To show | Call | Tutorial |
|---|---|---|
| Several columns over time | df.plot() |
Multiple columns on one line chart |
| Values by category | df.plot.bar(), df.plot.barh() |
Stacked vs unstacked bars |
| Group totals or a pivot table | df.groupby(...).sum().plot.bar() |
Plot groupby and pivot table results |
| Distributions | df.plot.hist(), df.plot.box(), df.hist(), df.boxplot() |
Histograms and box plots |
| Smoothed distributions | df.plot.kde() (needs SciPy) |
Seaborn kdeplot has more control |
| Parts of a total over time | df.plot.area() |
Matplotlib area charts |
| Two columns against each other | df.plot.scatter(x="a", y="b") |
Matplotlib scatter plots |
| Every pair of columns | pd.plotting.scatter_matrix(df) |
scatter_matrix |
| A trend under noisy data | df.rolling(7).mean().plot() |
Rolling averages |
| Dense scatter data | df.plot.hexbin(x="a", y="b") |
Hexbin plots |
| Shares of one total | df.plot.pie(y="col") |
Matplotlib pie charts |
To choose by how the chart looks, browse the Python Chart Gallery.
Customize pandas plots
| You want to | Tutorial |
|---|---|
| Change the figure size | figsize with df.plot |
| Put a second column on its own y-axis | Secondary y-axis |
| Add error bars | Error bars on DataFrame plots |
| Resample to weeks or months before plotting | Time series with a custom frequency |
| Print values on the bars | Matplotlib bar_label works on pandas bars through ax.containers |
| Format dates on the x-axis | Matplotlib date formatting |
How does df.plot work with Matplotlib?
pandas builds the chart with Matplotlib and gives you back the Axes:
ax = df.plot(...)returns the axes, soax.set_title(),ax.legend(),ax.bar_label(), and the rest of Matplotlib work on it.df.plot(ax=ax)draws onto axes you already made, for example one panel ofplt.subplots(2, 2).df.plot(subplots=True)gives each column its own panel and returns a NumPy array of axes.- Keyword arguments pandas doesn't use (
color,linewidth,marker,alpha) are passed on to Matplotlib.
The Matplotlib tutorial is the reference for anything you change after plotting.
Interactive charts from a DataFrame
df.plot makes static images. For hover, zoom, and pan, switch the backend or use a library that reads DataFrames directly:
pd.options.plotting.backend = "plotly"makesdf.plot()return a Plotly figure. See the Plotly plotting backend.import hvplot.pandasaddsdf.hvplot(), which takes nearly the same arguments asdf.plot(). See hvPlot.- Polars DataFrames have their own
df.plot, built on Altair. See plotting a Polars DataFrame.
Format a DataFrame as a table
Sometimes the right output is a well-formatted table rather than a chart:
df.styleadds number formats, color gradients, and highlights in Jupyter and HTML.- Great Tables makes publication-quality tables with titles, spanners, and footnotes.
Should I use pandas, Matplotlib, Seaborn, or Plotly?
| Choose | When |
|---|---|
df.plot() |
A quick look at a DataFrame that's already shaped the way you want to plot it (one column per series) |
| Matplotlib | You need full control of a static chart |
| Seaborn | Your data is in long format (one row per observation) and you want grouping, statistics, and color by category handled for you |
| Plotly | Readers need to hover, zoom, or filter |
The main difference between pandas and Seaborn is data shape. df.plot() wants wide data: one column per line or bar group. Seaborn wants long data plus hue="column". df.melt() turns wide into long, and df.pivot() goes the other way.
Common pandas plotting errors
| Problem | Cause | Fix |
|---|---|---|
TypeError: no numeric data to plot |
The columns are strings or object dtype |
Convert with pd.to_numeric(df["col"]) or df.astype(float) |
ValueError: scatter requires an x and y column |
kind="scatter" without x= and y= |
df.plot.scatter(x="a", y="b") |
ValueError: pie requires either y column or 'subplots=True' |
A pie on a DataFrame with several columns | df.plot.pie(y="col") |
| The plot doesn't appear | Not in a notebook, or no plt.show() |
Call plt.show(); see plot not showing |
figsize is ignored |
It was set on a different figure than the one pandas drew on | Pass figsize= to df.plot(), or make the figure first and pass ax= |
| Bars are in the wrong order | Bars follow the index order | Sort first: df.sort_values("col").plot.barh() |
ValueError: Must supply freq for datetime value or <MonthBegin> is not supported as period frequency from df.plot.bar() |
A bug in pandas 3.0.0 to 3.0.5 with dates on the x-axis of bar charts (pandas issue #67755) | Upgrade to pandas 3.0.6 or later. On an older 3.0 release, label the bars as text: df.set_axis(df.index.strftime("%b %Y")).plot.bar() |