Pandas VisualizationΒΆ

Pandas integrates directly with Matplotlib to provide a convenient .plot() method on DataFrames and Series. By specifying a kind parameter or using accessor methods like .plot.barh(), .plot.scatter(), and .plot.hist(), you can generate a variety of chart types with minimal code.

This notebook demonstrates line plots with custom titles and axis labels, horizontal stacked bar charts for composition analysis, scatter plots for relationship exploration, histograms for distribution analysis, box plots for identifying outliers and spread, area charts for cumulative comparisons, and pie charts for proportional breakdowns. Matplotlib style sheets (like classic) let you quickly change the overall visual appearance of your plots.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv(r"C:\Users\alexf\OneDrive\Documents\Pandas Tutorial\Ice Cream Ratings.csv")
df = df.set_index('Date')
df
print(plt.style.available)
plt.style.use('classic')
df.plot(kind = 'line', title = 'Ice Cream Ratings', xlabel = 'Daily Ratings', ylabel = 'Scores')
df.plot.barh(stacked = True)
df.plot.scatter(x = 'Texture Rating', y = 'Overall Rating', s = 500, c = 'Yellow')
df.plot.hist(bins = 10)
df.boxplot()
df.plot.area(figsize = (10,5))
df.plot.pie(y='Flavor Rating',figsize=(10,10))