# pandas Plotting Cheat Sheet: df.plot() Kinds and Options

> pandas plot cheat sheet with a downloadable one-page PNG: df.plot() line, bar, stacked bar, area, hist, box, kde, scatter and pie, plus figsize, colors, subplots, resample and savefig.

Source: https://www.pythoncharts.com/pandas/pandas-plotting-cheat-sheet/ | Published: 2026-12-06 | Author: Alex Scott | Category: Pandas | Tags: pandas, cheat-sheet, df.plot, bar chart, histogram, time series, python

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.

```python
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)
```

![pandas line chart of monthly revenue for online and stores, with online rising from 82 to 152 and stores falling from 116 to 88](https://www.pythoncharts.com/pandas/pandas-plotting-cheat-sheet/images/pandas-plotting-cheat-sheet-quick-example.png)

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)](https://www.pythoncharts.com/pandas/pandas-plotting-cheat-sheet/images/pandas-plotting-cheat-sheet.png). Every chart on it is drawn by the code printed beside it, with pandas 3.1 and Matplotlib 3.11.

![One page pandas plotting cheat sheet with setup code, twelve df.plot chart kinds each shown with its code, and reference panels for size and titles, colors and style, layout and labels, and preparing data and saving](https://www.pythoncharts.com/pandas/pandas-plotting-cheat-sheet/images/pandas-plotting-cheat-sheet.png)

## 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.

```python
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](https://www.pythoncharts.com/pandas/pandas-stacked-vs-unstacked-bar-charts/) | `q.plot.bar(stacked=True)` |
| Horizontal bar | `totals.plot.barh()` |
| Area (stacked by default) | `df.plot.area()` |
| [Histogram](https://www.pythoncharts.com/pandas/pandas-histogram-boxplot/) | `df["north"].plot.hist(bins=8)` |
| [Box](https://www.pythoncharts.com/pandas/pandas-histogram-boxplot/) | `df.plot.box()` |
| Density | `df.plot.kde()` |
| Scatter | `df.plot.scatter(x="north", y="south")` |
| Pie | `totals.plot.pie(autopct="%.0f%%")` |
| [Secondary y-axis](https://www.pythoncharts.com/pandas/secondary-y-axis-pandas/) | `df.plot(secondary_y="east")` |
| [Rolling average](https://www.pythoncharts.com/pandas/pandas-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`](https://www.pythoncharts.com/pandas/pandas-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()`<br>`ax.set_ylabel("Sales")` |

More on sizing in [changing the figure size of df.plot()](https://www.pythoncharts.com/pandas/change-figure-size-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)`<br>`df.plot(ax=axs[0])` |
| Legend position | `ax = df.plot()`<br>`ax.legend(loc="upper left")` |
| Rotate tick labels | `df.plot(rot=45)` |
| Bar value labels | `ax = totals.plot.bar()`<br>`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()`<br>`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](https://www.pythoncharts.com/pandas/pandas-plot-groupby/) and [time series with custom frequency](https://www.pythoncharts.com/pandas/pandas-time-series-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](https://www.pythoncharts.com/pandas/pandas-plotly-backend/)).

## 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](https://www.pythoncharts.com/matplotlib/matplotlib-cheat-sheet/), or reach for the [Seaborn cheat sheet](https://www.pythoncharts.com/seaborn/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 with `df.set_index("date")`.
- **Use `rot=0` on 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 needs `y="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.

## Similar Topics

- [Pandas Plotting: A Guide to df.plot() in Python](https://www.pythoncharts.com/pandas/pandas-plotting/)
- [Plot Multiple Columns on the Same Line Chart in Pandas](https://www.pythoncharts.com/pandas/multiple-columns-line-chart-pandas/)
- [Matplotlib Cheat Sheet: Plot Types and Common Commands](https://www.pythoncharts.com/matplotlib/matplotlib-cheat-sheet/)
