Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Colors in a 3-variable Plot | 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

bookColors in a 3-variable Plot

We also can change colors for the 3rd variable manually. To do that, we need to create a kind of a palette.

To set colors for a 3-variable plot:

It is important to create a new color palette for the hue variable and add this palette as an argument in the plot function.

The short list of the matplotlib colors: blue, green, red, green/blue, yellow, purple, white, black, etc.

Let's change gender colors in the Tips problem!

12345678910111213141516
# 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/bilibili.csv') # Setting colors for the hue variable hue_colors = {'woman':'red', 'man':'black'} # Creating the 3-variable scatterplot sns.scatterplot(x = 'bill', y = 'tips', hue = 'gender', data=df, palette = hue_colors) # Showing the plot plt.show()
copy
Завдання
test

Swipe to show code editor

  1. Set the 'blue' color for breakfast, 'purple' for lunch, 'green' for dinner for the hue value.
  2. Show the plot.

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

Як ми можемо покращити це?

Дякуємо за ваш відгук!

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

bookColors in a 3-variable Plot

We also can change colors for the 3rd variable manually. To do that, we need to create a kind of a palette.

To set colors for a 3-variable plot:

It is important to create a new color palette for the hue variable and add this palette as an argument in the plot function.

The short list of the matplotlib colors: blue, green, red, green/blue, yellow, purple, white, black, etc.

Let's change gender colors in the Tips problem!

12345678910111213141516
# 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/bilibili.csv') # Setting colors for the hue variable hue_colors = {'woman':'red', 'man':'black'} # Creating the 3-variable scatterplot sns.scatterplot(x = 'bill', y = 'tips', hue = 'gender', data=df, palette = hue_colors) # Showing the plot plt.show()
copy
Завдання
test

Swipe to show code editor

  1. Set the 'blue' color for breakfast, 'purple' for lunch, 'green' for dinner for the hue value.
  2. Show the plot.

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

Як ми можемо покращити це?

Дякуємо за ваш відгук!

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

bookColors in a 3-variable Plot

We also can change colors for the 3rd variable manually. To do that, we need to create a kind of a palette.

To set colors for a 3-variable plot:

It is important to create a new color palette for the hue variable and add this palette as an argument in the plot function.

The short list of the matplotlib colors: blue, green, red, green/blue, yellow, purple, white, black, etc.

Let's change gender colors in the Tips problem!

12345678910111213141516
# 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/bilibili.csv') # Setting colors for the hue variable hue_colors = {'woman':'red', 'man':'black'} # Creating the 3-variable scatterplot sns.scatterplot(x = 'bill', y = 'tips', hue = 'gender', data=df, palette = hue_colors) # Showing the plot plt.show()
copy
Завдання
test

Swipe to show code editor

  1. Set the 'blue' color for breakfast, 'purple' for lunch, 'green' for dinner for the hue value.
  2. Show the plot.

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

Як ми можемо покращити це?

Дякуємо за ваш відгук!

We also can change colors for the 3rd variable manually. To do that, we need to create a kind of a palette.

To set colors for a 3-variable plot:

It is important to create a new color palette for the hue variable and add this palette as an argument in the plot function.

The short list of the matplotlib colors: blue, green, red, green/blue, yellow, purple, white, black, etc.

Let's change gender colors in the Tips problem!

12345678910111213141516
# 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/bilibili.csv') # Setting colors for the hue variable hue_colors = {'woman':'red', 'man':'black'} # Creating the 3-variable scatterplot sns.scatterplot(x = 'bill', y = 'tips', hue = 'gender', data=df, palette = hue_colors) # Showing the plot plt.show()
copy
Завдання
test

Swipe to show code editor

  1. Set the 'blue' color for breakfast, 'purple' for lunch, 'green' for dinner for the hue value.
  2. Show the plot.

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