Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
3-variable Scatterplot | More and More Plots
First Dive into seaborn Visualization
course content

Зміст курсу

First Dive into seaborn Visualization

First Dive into seaborn Visualization

1. Nice to Meet you, seaborn!
2. More and More Plots
3. Plot Customization

3-variable Scatterplot

We figured out how to build a scatterplot based on 2 variables. But we can also create a plot based on 3 variables!

The 3rd variable is named hue.

An example of a 3-variable scatterplot:

To initialize a 3-variable scatterplot based on the pandas DataFrame, we need to input at least 4 parameters: x, y (columns-coordinates for the plot), hue (the third variable), and data (he DataFrame containing the data).

Look at the code below!

12345678910111213
# Importing libraries needed import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Reading the file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c5b4ea8f-8a30-439f-9625-ddf2effbd9ac/example5.csv') # Creating the 3-variable scatterplot sns.scatterplot(x = 'x', y = 'y', hue = 'gender', data= df) # Showing the plot plt.show()
copy

Let's solve a problem from a common example of using 3 variables on plots.

Tips problem

You have the following data:

  • What was the total bill of the visitor (bill);
  • What tips did he/she leave (tips);
  • Gender of the client (gender);
  • Daytime client visited the cafe (daytime).

Завдання

  1. Import the seaborn with sns alias.
  2. Import the matplotlib.pyplot with plt alias.
  3. Import the pandas with pd alias.
  4. Create a scatterplot using 'bill' column for the x-value and 'tips' column for the y-value and 'daytime' for the hue-value using df dataset.
  5. Show the plot.

Завдання

  1. Import the seaborn with sns alias.
  2. Import the matplotlib.pyplot with plt alias.
  3. Import the pandas with pd alias.
  4. Create a scatterplot using 'bill' column for the x-value and 'tips' column for the y-value and 'daytime' for the hue-value using df dataset.
  5. Show the plot.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 3
toggle bottom row

3-variable Scatterplot

We figured out how to build a scatterplot based on 2 variables. But we can also create a plot based on 3 variables!

The 3rd variable is named hue.

An example of a 3-variable scatterplot:

To initialize a 3-variable scatterplot based on the pandas DataFrame, we need to input at least 4 parameters: x, y (columns-coordinates for the plot), hue (the third variable), and data (he DataFrame containing the data).

Look at the code below!

12345678910111213
# Importing libraries needed import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Reading the file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c5b4ea8f-8a30-439f-9625-ddf2effbd9ac/example5.csv') # Creating the 3-variable scatterplot sns.scatterplot(x = 'x', y = 'y', hue = 'gender', data= df) # Showing the plot plt.show()
copy

Let's solve a problem from a common example of using 3 variables on plots.

Tips problem

You have the following data:

  • What was the total bill of the visitor (bill);
  • What tips did he/she leave (tips);
  • Gender of the client (gender);
  • Daytime client visited the cafe (daytime).

Завдання

  1. Import the seaborn with sns alias.
  2. Import the matplotlib.pyplot with plt alias.
  3. Import the pandas with pd alias.
  4. Create a scatterplot using 'bill' column for the x-value and 'tips' column for the y-value and 'daytime' for the hue-value using df dataset.
  5. Show the plot.

Завдання

  1. Import the seaborn with sns alias.
  2. Import the matplotlib.pyplot with plt alias.
  3. Import the pandas with pd alias.
  4. Create a scatterplot using 'bill' column for the x-value and 'tips' column for the y-value and 'daytime' for the hue-value using df dataset.
  5. Show the plot.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

Секція 2. Розділ 3
toggle bottom row

3-variable Scatterplot

We figured out how to build a scatterplot based on 2 variables. But we can also create a plot based on 3 variables!

The 3rd variable is named hue.

An example of a 3-variable scatterplot:

To initialize a 3-variable scatterplot based on the pandas DataFrame, we need to input at least 4 parameters: x, y (columns-coordinates for the plot), hue (the third variable), and data (he DataFrame containing the data).

Look at the code below!

12345678910111213
# Importing libraries needed import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Reading the file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c5b4ea8f-8a30-439f-9625-ddf2effbd9ac/example5.csv') # Creating the 3-variable scatterplot sns.scatterplot(x = 'x', y = 'y', hue = 'gender', data= df) # Showing the plot plt.show()
copy

Let's solve a problem from a common example of using 3 variables on plots.

Tips problem

You have the following data:

  • What was the total bill of the visitor (bill);
  • What tips did he/she leave (tips);
  • Gender of the client (gender);
  • Daytime client visited the cafe (daytime).

Завдання

  1. Import the seaborn with sns alias.
  2. Import the matplotlib.pyplot with plt alias.
  3. Import the pandas with pd alias.
  4. Create a scatterplot using 'bill' column for the x-value and 'tips' column for the y-value and 'daytime' for the hue-value using df dataset.
  5. Show the plot.

Завдання

  1. Import the seaborn with sns alias.
  2. Import the matplotlib.pyplot with plt alias.
  3. Import the pandas with pd alias.
  4. Create a scatterplot using 'bill' column for the x-value and 'tips' column for the y-value and 'daytime' for the hue-value using df dataset.
  5. Show the plot.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів

Все було зрозуміло?

We figured out how to build a scatterplot based on 2 variables. But we can also create a plot based on 3 variables!

The 3rd variable is named hue.

An example of a 3-variable scatterplot:

To initialize a 3-variable scatterplot based on the pandas DataFrame, we need to input at least 4 parameters: x, y (columns-coordinates for the plot), hue (the third variable), and data (he DataFrame containing the data).

Look at the code below!

12345678910111213
# Importing libraries needed import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # Reading the file df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c5b4ea8f-8a30-439f-9625-ddf2effbd9ac/example5.csv') # Creating the 3-variable scatterplot sns.scatterplot(x = 'x', y = 'y', hue = 'gender', data= df) # Showing the plot plt.show()
copy

Let's solve a problem from a common example of using 3 variables on plots.

Tips problem

You have the following data:

  • What was the total bill of the visitor (bill);
  • What tips did he/she leave (tips);
  • Gender of the client (gender);
  • Daytime client visited the cafe (daytime).

Завдання

  1. Import the seaborn with sns alias.
  2. Import the matplotlib.pyplot with plt alias.
  3. Import the pandas with pd alias.
  4. Create a scatterplot using 'bill' column for the x-value and 'tips' column for the y-value and 'daytime' for the hue-value using df dataset.
  5. Show the plot.

Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Секція 2. Розділ 3
Перейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
We're sorry to hear that something went wrong. What happened?
some-alt