Skip to main content
Albero Academy

Plotting with pandas

Quick charts straight from a DataFrame with .plot.

Applied Pandas8 min

Pandas has built-in plotting via .plot (backed by Matplotlib) — the fastest way to see your data during analysis, without leaving the DataFrame.

Plot kinds

.plot straight from data
ts["sales"].plot() # line (great for time series)
df["package"].plot(kind="hist", bins=20) # distribution
df["programme"].value_counts().plot(kind="bar") # category counts
df.plot(kind="scatter", x="age", y="package") # relationship

Plotting grouped results

aggregate then plot
(df.groupby("programme")["package"].mean()
.plot(kind="barh", title="Avg package by programme"))

Key takeaways

  1. 01df/Series .plot() draws quick charts backed by Matplotlib.
  2. 02kind= selects line, hist, bar, barh, scatter, box and more.
  3. 03Plot aggregated results by chaining .plot after groupby.
  4. 04Use it for exploration; use Matplotlib/Seaborn for polished visuals.

Finished this chapter?

Mark it complete to track your progress through Pandas.