Data Visualization with Matplotlib, Seaborn Plotly 📊📈
1️⃣ Matplotlib – Basic Plotting
Great for simple line, bar, and scatter plots.
Import and Line Plot
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [10, 20, 25, 30]
plt.plot(x, y)
plt.title("Line Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()
Bar Plot
names = ["A", "B", "C"]
scores = [80, 90, 70]
plt.bar(names, scores)
plt.title("Scores by Name")
plt.show()
2️⃣ Seaborn – Statistical Visualization
Built on Matplotlib with better styling.
Import and Plot
import seaborn as sns
import pandas as pd
df = pd.DataFrame({
"Name": ["Riya", "Aman", "John", "Sara"],
"Score": [85, 92, 78, 88]
})
sns.barplot(x="Name", y="Score", data=df)
Other Seaborn Plots
sns.histplot(df["Score"]) # Histogram
sns.boxplot(x=df["Score"]) # Box plot
3️⃣ Plotly – Interactive Graphs
Great for dashboards and interactivity.
Basic Line Plot
import plotly.express as px
df = pd.DataFrame({
"x": [1, 2, 3],
"y": [10, 20, 15]
})
fig = px.line(df, x="x", y="y", title="Interactive Line Plot")
fig.show()
🎯 Why Visualization Matters
• Helps spot patterns in data
• Makes insights clear and shareable
• Supports better decision-making
Practice Task:
• Create a line plot using matplotlib
• Use seaborn to plot a boxplot for scores
• Try any interactive chart using plotly
💬 Tap ❤️ for more