To plot a pandas DataFrame, call df.plot(): it draws one line per column against the index, and df.plot.bar(), df.plot.hist(), df.plot.box() and the other kinds change the chart. It returns a Matplotlib Axes, so everything in Matplotlib still works on the result. This cheat sheet puts the kinds and the options you reach for most on one page.
Quick Example
Two lines from a DataFrame with a date index, with colors, markers, a title, and a grid. The data is made up (seeded) so the chart is reproducible.
import numpy as np
import pandas as pd
rng = np.random.default_rng(31)
months = pd.date_range("2026-01-01", periods=12, freq="MS")
df = pd.DataFrame({"online": 80 + np.cumsum(rng.normal(4, 5, 12)),
"stores": 120 + np.cumsum(rng.normal(-1, 5, 12))}, index=months)
ax = df.plot(figsize=(8, 4.5), color=["#0f766e", "#f59e0b"], marker="o",
title="Monthly revenue by channel", xlabel="", ylabel="Revenue ($k)")
ax.grid(alpha=0.3)

Online revenue climbs from 82 in January to 152 in December, while stores slip from 116 to 88, so online passes stores in July.
Download the pandas Plotting Cheat Sheet
Download the full-size cheat sheet (PNG). Every chart on it is drawn by the code printed beside it, with pandas 3.1 and Matplotlib 3.11.

Setup Code for the Examples
The snippets in the tables use these variables: 24 months of made-up sales for three regions, the totals per region, and the totals per quarter.
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
rng = np.random.default_rng(8)
months = pd.date_range("2026-01-01", periods=24, freq="MS")
df = pd.DataFrame(
{"north": 50 + np.cumsum(rng.normal(2, 4, 24)),
"south": 45 + np.cumsum(rng.normal(1, 4, 24)),
"east": 30 + np.cumsum(rng.normal(3, 3, 24))},
index=months)
totals = df.sum()
q = df.groupby(df.index.quarter).sum()
pandas Plot Kinds
Each kind has two spellings: df.plot(kind="bar") and df.plot.bar(). They are the same, and the second autocompletes.
| Chart (links to guide) | Code |
|---|---|
| Line (one per column) | df.plot() |
| Bar | totals.plot.bar() |
| Stacked bar | q.plot.bar(stacked=True) |
| Horizontal bar | totals.plot.barh() |
| Area (stacked by default) | df.plot.area() |
| Histogram | df["north"].plot.hist(bins=8) |
| Box | df.plot.box() |
| Density | df.plot.kde() |
| Scatter | df.plot.scatter(x="north", y="south") |
| Pie | totals.plot.pie(autopct="%.0f%%") |
| Secondary y-axis | df.plot(secondary_y="east") |
| Rolling average | df["north"].rolling(3).mean().plot() |
df.plot.kde() needs SciPy installed. df.plot.hexbin() and df.plot.density() (an alias of kde) are also available, and scatter_matrix plots every pair of columns.
Size, Titles, and Limits
| Task | Code |
|---|---|
| Figure size | df.plot(figsize=(8, 4)) |
| Title | df.plot(title="Sales") |
| Axis labels | df.plot(xlabel="Month", ylabel="Sales") |
| Y limits | df.plot(ylim=(0, 100)) |
| Log scale | df.plot(logy=True) |
| Keep the Axes | ax = df.plot()ax.set_ylabel("Sales") |
More on sizing in changing the figure size of df.plot().
Colors and Style
| Task | Code |
|---|---|
| Colors, one per column | df.plot(color=["#0f766e", "#94a3b8", "#f59e0b"]) |
| Line styles | df.plot(style=["o-", "s--", "^:"]) |
| Colormap | df.plot(colormap="viridis") |
| Transparency | df.plot(alpha=0.6) |
| Hide legend | df.plot(legend=False) |
| Style sheet | plt.style.use("ggplot") |
Layout and Labels
| Task | Code |
|---|---|
| One panel per column | df.plot(subplots=True, layout=(2, 2), sharex=True) |
| Draw on an Axes | fig, axs = plt.subplots(1, 2)df.plot(ax=axs[0]) |
| Legend position | ax = df.plot()ax.legend(loc="upper left") |
| Rotate tick labels | df.plot(rot=45) |
| Bar value labels | ax = totals.plot.bar()ax.bar_label(ax.containers[0]) |
| Pick x and y | df.plot(x="north", y=["south", "east"]) |
df.plot() on a DataFrame opens a new figure unless you pass ax=; a Series plot draws on the current Axes. To put several pandas charts in one figure, create the axes first and pass each as ax=.
Prepare the Data, Then Save
| Task | Code |
|---|---|
| Resample first | df.resample("QE").sum().plot() |
| Sort, then plot | totals.sort_values().plot.barh() |
| Transpose | df.tail(3).T.plot.bar() |
| Group, then plot | df.groupby(df.index.year).mean().plot.bar() |
| Save | ax = df.plot()ax.figure.savefig("plot.png", dpi=200, bbox_inches="tight") |
| Plotly backend | pd.options.plotting.backend = "plotly" |
Most plotting problems are data-shape problems: columns become lines or bars, and the index becomes the x-axis. See plotting GroupBy and pivot tables and time series with custom frequency. "QE" (quarter end) is the pandas 2.2+ spelling; older versions use "Q". The Plotly backend turns df.plot() into an interactive chart (how to switch backends).
When Should I Use pandas Plotting Instead of Matplotlib or Seaborn?
df.plot() |
Matplotlib | Seaborn | |
|---|---|---|---|
| Code for a quick look | One call on the DataFrame | Loop over columns | One call with data=, hue= |
| Index as the x-axis | Automatic | Pass it yourself | Reset the index first |
| Grouped statistics | Aggregate first | Aggregate first | Built in (barplot, lineplot) |
| Custom layouts | Via ax= |
Full control | Via ax= |
For a fast look at a DataFrame, use df.plot(). When you need a layout pandas can't make, take the Axes it returns and carry on in the Matplotlib cheat sheet, or reach for the Seaborn cheat sheet when you want groups and error bars computed for you.
Practical Tips
- Columns become series and the index becomes x. If the chart looks transposed, call
.T; if the x-axis is 0, 1, 2, set the index first withdf.set_index("date"). - Use
rot=0on bar charts with short labels. pandas rotates bar tick labels 90 degrees by default. df.plot(subplots=True)returns an array of Axes, not one Axes.kind="pie"on a DataFrame needsy="column". On a Series it works directly.- Stacked bars and areas assume the columns add up. Don't stack columns that overlap, such as a total and its parts.