Plotsdecoratie
Stijl instellen
seaborn
biedt de functie set_style()
specifiek voor het instellen van de visuele stijl van uw grafieken. Deze functie vereist één verplichte parameter genaamd style
. De parameter style
accepteert verschillende vooraf gedefinieerde opties, die elk een onderscheidende stijl vertegenwoordigen:
'white'
'dark'
'whitegrid'
'darkgrid'
'ticks'
Experimenteer gerust met deze opties:
12345678910import seaborn as sns import matplotlib.pyplot as plt # Setting the style sns.set_style('darkgrid') titanic_df = sns.load_dataset('titanic') sns.countplot(data=titanic_df, x='class') plt.show()
Palet instellen
Een andere mogelijkheid is het wijzigen van de kleuren van plot-elementen in seaborn
met behulp van de functie set_palette()
, waarbij de enige verplichte parameter palette
centraal staat:
- Circulaire paletten:
'hls'
,'husl'
; - Perceptueel uniforme paletten:
'rocket'
,'magma'
,'mako'
, enz.; - Divergerende kleurpaletten:
'RdBu'
,'PRGn'
, enz.; - Sequentiële kleurpaletten:
'Greys'
,'Blues'
, enz.
Je kunt meer ontdekken over verschillende paletten in het "Choosing color palettes" artikel.
1234567891011121314import seaborn as sns import matplotlib.pyplot as plt # Setting the style sns.set_style('darkgrid') # Setting the palette sns.set_palette('magma') # Loading a built-in dataset of the Titanic passengers titanic_df = sns.load_dataset('titanic') sns.countplot(data=titanic_df, x='class') plt.show()
Context Instellen
Er is een andere functie in de seaborn
-bibliotheek, set_context()
. Deze beïnvloedt aspecten zoals de grootte van de labels, lijnen en andere elementen van de plot (de algemene stijl wordt niet beïnvloed).
De belangrijkste parameter is context
, die een dict
van parameters kan zijn of een string
die de naam van een vooraf ingestelde set vertegenwoordigt.
De standaard context
is 'notebook'
. Andere beschikbare contexten zijn 'paper'
, 'talk'
en 'poster'
, die in wezen geschaalde versies zijn van de notebook
-parameters.
1234567891011121314151617import seaborn as sns import matplotlib.pyplot as plt # Setting the style sns.set_style('darkgrid') # Setting the palette sns.set_palette('magma') # Setting the context sns.set_context('paper') # Loading a built-in dataset of the Titanic passengers titanic_df = sns.load_dataset('titanic') sns.countplot(data=titanic_df, x='class') plt.show()
Je kunt meer ontdekken in de set_context()
documentatie.
Swipe to start coding
- Gebruik de juiste functie om de stijl in te stellen op
'dark'
. - Gebruik de juiste functie om het palet in te stellen op
'rocket'
. - Gebruik de juiste functie om de context in te stellen op
'talk'
.
Oplossing
Bedankt voor je feedback!
single
Vraag AI
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.
Awesome!
Completion rate improved to 3.85
Plotsdecoratie
Veeg om het menu te tonen
Stijl instellen
seaborn
biedt de functie set_style()
specifiek voor het instellen van de visuele stijl van uw grafieken. Deze functie vereist één verplichte parameter genaamd style
. De parameter style
accepteert verschillende vooraf gedefinieerde opties, die elk een onderscheidende stijl vertegenwoordigen:
'white'
'dark'
'whitegrid'
'darkgrid'
'ticks'
Experimenteer gerust met deze opties:
12345678910import seaborn as sns import matplotlib.pyplot as plt # Setting the style sns.set_style('darkgrid') titanic_df = sns.load_dataset('titanic') sns.countplot(data=titanic_df, x='class') plt.show()
Palet instellen
Een andere mogelijkheid is het wijzigen van de kleuren van plot-elementen in seaborn
met behulp van de functie set_palette()
, waarbij de enige verplichte parameter palette
centraal staat:
- Circulaire paletten:
'hls'
,'husl'
; - Perceptueel uniforme paletten:
'rocket'
,'magma'
,'mako'
, enz.; - Divergerende kleurpaletten:
'RdBu'
,'PRGn'
, enz.; - Sequentiële kleurpaletten:
'Greys'
,'Blues'
, enz.
Je kunt meer ontdekken over verschillende paletten in het "Choosing color palettes" artikel.
1234567891011121314import seaborn as sns import matplotlib.pyplot as plt # Setting the style sns.set_style('darkgrid') # Setting the palette sns.set_palette('magma') # Loading a built-in dataset of the Titanic passengers titanic_df = sns.load_dataset('titanic') sns.countplot(data=titanic_df, x='class') plt.show()
Context Instellen
Er is een andere functie in de seaborn
-bibliotheek, set_context()
. Deze beïnvloedt aspecten zoals de grootte van de labels, lijnen en andere elementen van de plot (de algemene stijl wordt niet beïnvloed).
De belangrijkste parameter is context
, die een dict
van parameters kan zijn of een string
die de naam van een vooraf ingestelde set vertegenwoordigt.
De standaard context
is 'notebook'
. Andere beschikbare contexten zijn 'paper'
, 'talk'
en 'poster'
, die in wezen geschaalde versies zijn van de notebook
-parameters.
1234567891011121314151617import seaborn as sns import matplotlib.pyplot as plt # Setting the style sns.set_style('darkgrid') # Setting the palette sns.set_palette('magma') # Setting the context sns.set_context('paper') # Loading a built-in dataset of the Titanic passengers titanic_df = sns.load_dataset('titanic') sns.countplot(data=titanic_df, x='class') plt.show()
Je kunt meer ontdekken in de set_context()
documentatie.
Swipe to start coding
- Gebruik de juiste functie om de stijl in te stellen op
'dark'
. - Gebruik de juiste functie om het palet in te stellen op
'rocket'
. - Gebruik de juiste functie om de context in te stellen op
'talk'
.
Oplossing
Bedankt voor je feedback!
Awesome!
Completion rate improved to 3.85single