0% found this document useful (0 votes)
2 views7 pages

Data Visualization Using Matplotlib and Seaborn

The document outlines activities for data visualization using Matplotlib and Seaborn, including basic plotting, exploring datasets, and creating statistical visualizations like boxplots and heatmaps. It highlights the differences between Matplotlib and Seaborn, emphasizing Seaborn's ease of use and aesthetic appeal. Additionally, it includes assessment tasks and interpretations of visualizations created from real datasets.

Uploaded by

Elaiza Cultura
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Data Visualization Using Matplotlib and Seaborn

The document outlines activities for data visualization using Matplotlib and Seaborn, including basic plotting, exploring datasets, and creating statistical visualizations like boxplots and heatmaps. It highlights the differences between Matplotlib and Seaborn, emphasizing Seaborn's ease of use and aesthetic appeal. Additionally, it includes assessment tasks and interpretations of visualizations created from real datasets.

Uploaded by

Elaiza Cultura
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Data Visualization using Matplotlib and Seaborn

Activity 1: Basic Plotting with Matplotlib

Objective: Create simple plots using Matplotlib.

Output: A blue line graph with circle markers, dashed line style, axis labels, and a grid.

Activity 2: Exploring Seaborn Datasets

Objective: Use Seaborn to visualize built-in datasets.

Output: A colorful scatterplot showing relationships and categories.


Activity 3 — Statistical Visualization

Objective: Create boxplots and heatmaps.

Output:

 A boxplot comparing total bill amounts for each day (Thur, Fri, Sat, Sun).

import seaborn as sns

import [Link] as plt

# Boxplot of total bill per day

[Link](data=tips, x='day', y='total_bill', palette='coolwarm')

[Link]('Boxplot of Total Bill by Day')

[Link]()
Output: A heatmap showing correlations between numeric columns (total_bill, tip, size).
Activity 4 — Combining Matplotlib + Seaborn

Objective: Customize Seaborn using Matplotlib commands.

Output:

A bar chart showing the average total bill for each day, separated by gender.

[Link](figsize=(8,5))

[Link](data=tips, x='day', y='total_bill', hue='sex')

[Link]('Average Total Bill per Day by Gender', fontsize=14)

[Link]('Day of the Week')

[Link]('Average Bill')

[Link](title='Gender')

[Link]()

VI. Assessment Tasks

1. What is the main difference between Matplotlib and Seaborn?


Matplotlib is a foundational plotting library in Python that gives you full control over every
element of a plot, making it very flexible, but it often requires writing more code to achieve
visually appealing results. Seaborn, on the other hand, is built on top of Matplotlib and is
designed to simplify the creation of attractive and informative statistical plots. It comes with built-
in themes, color palettes, and easy-to-use functions, allowing you to produce complex
visualizations with much less effort. Essentially, Matplotlib is like the manual toolkit for plotting,
while Seaborn is the ready-made stylish toolkit that makes your charts look polished instantly.

2. List three advantages of using Seaborn for data visualization:

 Ease of Creating Complex Plots: Seaborn makes it simple to generate sophisticated


statistical visualizations such as violin plots, boxplots, scatterplots, and heatmaps
without writing extensive code.

 Beautiful Default Styles and Color Palettes: Seaborn automatically applies modern
themes and color schemes, which makes your charts visually appealing and
professional-looking right out of the box.

 Seamless Integration with Pandas DataFrames: Seaborn works directly with pandas
DataFrames, allowing you to reference column names and create plots quickly, reducing
the need for manual data preprocessing.

3. Define correlation heatmap and explain its purpose:

A correlation heatmap is a type of visualization that shows how numerical variables in a


dataset are related to one another using correlation coefficients. The heatmap uses color
gradients to indicate the strength and direction of these relationships, making it easy to spot
strong positive correlations, negative correlations, or variables that are largely independent. Its
main purpose is to help analysts quickly identify patterns, trends, and potential dependencies
between variables, which is especially useful for data exploration, hypothesis generation, and
decision-making.
2. Performance Task:

 Using a real dataset (e.g., student performance, sales data, COVID-19 data), create at
least three different types of visualizations using both Matplotlib and Seaborn.
 Add proper titles, axis labels, legends, and color themes.
 Interpret each visualization in a short paragraph.

Interpretation: The line plot shows each student’s performance across subjects. Student 7
consistently scores the highest in Math and Science, while student 3 has the lowest scores,
highlighting variation in academic performance.
Interpretation: The scatter plot reveals a positive relationship between study hours and Math
scores. Students who study more hours tend to achieve higher scores, emphasizing the impact
of dedicated study time on performance.

Interpretation: The heatmap shows strong positive correlations between Math and Science
scores, indicating students who excel in Math also perform well in science. Study hours also
positively correlate with scores, suggesting that increased study time contributes to better
performance.

You might also like