this is the nav!
Introduction to Data Visualization with Seaborn
• AI Chat
• Code
• Report
• ## .mfe-app-workspace-kj242g{position:absolute;top:-8px;}.mfe-app-workspace-11ezf91{display:inline-block;}.mfe-app-workspace-11ezf91:hover .Anchor__copyLink{visibility:visible;}Introduction to Data Visualization with Seaborn

Run the hidden code cell below to import the data used in this course.

```.mfe-app-workspace-11z5vno{font-family:JetBrainsMonoNL,Menlo,Monaco,'Courier New',monospace;font-size:13px;line-height:20px;}```# Importing the course packages
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

# Importing the course datasets

### Making a count plot with a list

• Import Matplotlib and Seaborn using the standard naming conventions.

• Use Seaborn to create a count plot with region on the y-axis.

• Display the plot.

``````region = country_data['Region']
region``````
``````import matplotlib.pyplot as plt

sns.countplot(y=region)

plt.show()``````

### Making a count plot with a DataFrame

• Create a DataFrame named df from the csv file located at csv_filepath.

• Use the countplot() function with the x= and data= arguments to create a count plot with the "Region" column values on the x-axis.

• Display the plot.

``````# Spawning the data
data = country_data

# Creating the countplot with seaborn
sns.countplot(x="Region", data= data)

# show the plot
plt.show()``````
Hidden output

• Create a scatter plot with "absences" on the x-axis and final grade ("G3") on the y-axis using the DataFrame student_data. Color the plot points based on "location" (urban vs. rural).
• Set "Rural" before "Urban" using the "hue_order"
``````sns.scatterplot(x='absences',y='G3', data=student_data, hue='location',
hue_order=["Rural", "Urban"])

plt.show()``````
• Fill in the palette_colors dictionary to map the "Rural" location value to the color "green" and the "Urban" location value to the color "blue".

• Create a count plot with "school" on the x-axis using the student_data DataFrame.

• Add subgroups to the plot using "location" variable and use the palette_colors dictionary to make the location subgroups green and blue.

``````palette_colors = {"Rural":"green","Urban":"blue"}

sns.countplot(x="school",data=student_data, hue='location',palette=palette_colors)

plt.show()``````

### Creating subplots using "relplot()"

Modify the code to use relplot() instead of scatterplot().

``````sns.relplot(x='absences', y='G3',data=student_data,kind="scatter")

plt.show()``````

Modify the code to create one scatter plot for each level of the variable "study_time", arranged in columns.