Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Decoration and...Decoration! | Plot Customization
First Dive into seaborn Visualization

book
Decoration and...Decoration!

Setting the style for the plot

To set the style use:

python
sns.set_style('style_name')

Styles available: white, dark, whitegrid, darkgrid, ticks etc.

Changing colors of the main elements of the plot

seaborn has different palette options. Below there are a few of them.

Palettes: RdBu, PRGn, RdBu_r, PRGn_r (different colors in the palette), Greys, Blues, PuRd, GnBu (gradient colors).

You can also create your unique palette by creating a list variable. To set the palette use:

python
sns.set_palette(palette_name)

Context setting

To set the context use:

python
sns.set_context('context_name')

Contexts available: paper, notebook, talk, poster etc.

Taak

Swipe to start coding

  1. Import seaborn with sns alias.
  2. Import matplotlib.pyplot with plt alias.
  3. Import pandas with pd alias.
  4. Set the 'whitegrid' style.
  5. Set the 'paper' context.
  6. Rotate labels along the Ox axis by 45 degrees.

Oplossing

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd

df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c5b4ea8f-8a30-439f-9625-ddf2effbd9ac/bamboo.csv')

sns.set_style('whitegrid')

sns.set_context('paper')

sns.countplot(x = 'Bamboo', data = df)

plt.xticks(rotation = 45)

plt.show()

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 3. Hoofdstuk 4
# Importing libraries needed
___
___
___

# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/c5b4ea8f-8a30-439f-9625-ddf2effbd9ac/bamboo.csv')

# Set the style
___.___('___')

# Set the scale
___

# Creating the countplot
sns.countplot(x = 'Bamboo', data = df)

# Rotate
plt.___(___)

# Showing the plot
plt.show()

Vraag AI

expand
ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt