Pandas Plotting
Pandas Plotting
Pandas provides built-in plotting functions that make data visualization simple. These functions internally use Matplotlib, so you get quick plots with minimal code.

1. Basic Plotting Syntax
or for a specific column:
2. Common Plot Types in Pandas
| Plot Type | Use |
|---|---|
line |
Trends over time |
bar |
Category comparison |
barh |
Horizontal bars |
hist |
Distribution |
scatter |
Relationship between two variables |
box |
Outliers & spread |
area |
Cumulative values |
pie |
Proportion |
3. Line Plot Example (Most Common)
data = {
“Day”: [1, 2, 3, 4, 5],
“Sales”: [200, 300, 250, 400, 500]
}
df = pd.DataFrame(data)
df.plot(x=“Day”, y=“Sales”, kind=“line”)
plt.show()
Use case: Sales trend, stock prices, temperature over time
4. Bar Plot Example
df = pd.DataFrame(data)
df.plot(x=“Product”, y=“Revenue”, kind=“bar”)
plt.show()
Use case: Comparing categories
5. Histogram Example
df = pd.DataFrame(data)
df[“Marks”].plot(kind=“hist”, bins=5)
plt.show()
Use case: Data distribution
6. Scatter Plot Example
df = pd.DataFrame(data)
df.plot(x=“StudyHours”, y=“Marks”, kind=“scatter”)
plt.show()
Use case: Relationship between variables
7. Box Plot Example
df.plot(kind=“box”)
plt.show()
Use case: Detecting outliers
8. Multiple Columns Plot
df = pd.DataFrame(data)
df.plot(x=“Year”)
plt.show()
9. Customizing Plots
10. Real-World Example
Key Points
✔ Pandas plotting is fast and beginner-friendly
✔ Uses Matplotlib internally
✔ Best for quick analysis & exploration
Conclusion
Pandas plotting allows you to visualize data with very little code, making it ideal for exploratory data analysis before advanced visualization.
