For exploration you don't need a separate charting script — pandas plots straight from a DataFrame via .plot (backed by matplotlib). It's built for the quick "let me see it" visuals that guide analysis, not final presentation graphics.
The .plot method
import matplotlib.pyplot as pltts["sales"].plot() # line chart (index on x)df["package"].plot(kind="hist", bins=20) # distributionplt.show()
Chart kinds
| kind | Shows |
|---|---|
| line | Trend over an ordered axis (time) |
| bar / barh | Compare categories |
| hist | Distribution of one numeric column |
| box | Spread & outliers across groups |
| scatter | Relationship between two numerics |
| area / pie | Composition |
df.groupby("programme")["package"].mean().plot(kind="bar")df.plot(kind="scatter", x="experience", y="package")df.boxplot(column="package", by="programme")
Plotting grouped data
Aggregate first, then plot — the aggregated table is the chart data:
(df.groupby("year")["sales"].sum().plot(kind="line", marker="o", title="Sales by year"))# unstack a two-key group into a grouped/stacked bar(df.groupby(["year", "programme"])["package"].mean().unstack("programme").plot(kind="bar"))
Quick polish
ax = df["package"].plot(kind="hist", bins=15, figsize=(8, 4),title="Package distribution")ax.set_xlabel("Package (LPA)")ax.set_ylabel("Students")plt.tight_layout()
Practice
Plot a time series as a line chart, a numeric column as a histogram, and a group average as a bar chart. Make a scatter of two numeric columns and eyeball the relationship. Add a title and axis labels to one of them.
Key takeaways
- 01df.plot() / series.plot() chart directly from pandas, backed by matplotlib.
- 02Pick kind by intent: line (trend), bar (compare), hist/box (distribution), scatter (relationship).
- 03Aggregate with groupby first; the resulting table is the chart data (unstack for grouped bars).
- 04Set title, figsize and axis labels via the returned Axes for a quick polish.
- 05Use pandas plotting to explore; switch to seaborn/matplotlib/Plotly for presentation.
