← Back to Dashboard

Data Visualization Matplotlib Seaborn: Concept Notes

"""
Topic 09: Data Visualization (Matplotlib & Seaborn) - Concept Notes

Data visualization is the graphical representation of information and data. By using visual elements like charts, graphs, and maps, data visualization tools provide an accessible way to see and understand trends, outliers, and patterns in data.

1. Matplotlib
   - A low-level library for creating static, animated, and interactive visualizations.
   - Core object: Pyplot module.
   - Basic plots: Line, Bar, Scatter, Histogram, Pie.

2. Seaborn
   - A high-level library based on Matplotlib.
   - Provides a more aesthetically pleasing and statistically oriented interface.
   - Built-in themes and color palettes.
   - Advanced plots: Boxplot, Heatmap, Pairplot, Violinplot.
"""

# 1. Matplotlib Basics
import matplotlib.pyplot as plt
import numpy as np

# Preparing Data
x = np.linspace(0, 10, 100)
y = np.sin(x)

# Creating a Line Plot
plt.figure(figsize=(8, 4))
plt.plot(x, y, label='Sine Wave', color='blue', linestyle='--')
plt.title('Basic Sine Wave')
plt.xlabel('X axis')
plt.ylabel('Y axis')
plt.legend()
# plt.show() # Uncomment to see the plot

# 2. Seaborn Basics
import seaborn as sns
import pandas as pd

# Setting Style
sns.set_theme(style="darkgrid")

# Sample Data (built-in tips dataset)
# tips = sns.load_dataset("tips") 

# Creating a Scatter Plot with regression line
# sns.lmplot(data=tips, x="total_bill", y="tip", hue="smoker")
# plt.title('Tip vs Total Bill')

# 3. Customization
# Titles, Labels, Colors, Axes, and Themes.