JointGrid
JointGrid
is a figure-level function, when the function is called a JointGrid object is instantiated. The function creates a JointGrid object consisting of three axes objects but does not plot anything on it.






python9912345678910111213141516import pandas as pdimport seaborn as snsfrom matplotlib import pyplot as pltdf = pd.read_csv('filename.csv')# Creating the JointGrid variableg = sns.JointGrid(x = 'column_name', y = 'column_name', data = df)# Creating the inside plotg.plot_joint(sns.scatterplot)# Creating the outside plotg.plot_marginals(sns.histplot)plt.show()
Taak
Swipe to start coding
- Set the
'ticks'
style with the'lightcyan'
figure.facecolor
. - Create a
JointGrid
variableg
:
- Set the
x
parameter equals the'bill_length_mm'
; - Set the
y
parameter equals the'bill_depth_mm'
; - Set the
hue
parameter equals the'species'
; - Set the
'viridis'
palette; - Set the data.
Set the inside plot using the .plot_joint()
function using the g
variable:
- Create a
scatterplot
using theseaborn
; - Set the
alpha
parameter equals0.5
; - Set the
'pink'
edgecolor
parameter; - Set the
linewidth
parameter equals1
.
Set the outside plot using the .plot_marginals()
function:
- Create the
histplot
using theseaborn
; - Add the
kde
parameter.
Oplossing
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import warnings
# Ignore all warnings
warnings.filterwarnings('ignore')
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/penguins_upd.csv')
# Set the 'ticks' style with the 'lightcyan' facecolor
sns.set_style('ticks', {'figure.facecolor' : 'lightcyan'})
# Create a JointGrid variable
g = sns.JointGrid(# Set the x
x = 'bill_length_mm',
# Set the y
y = 'bill_depth_mm',
# Set the hue
hue = 'species',
# Set the palette
palette = 'viridis',
# Set the data
data = df)
# Set the inside plot using the .plot_joint() function
g.plot_joint(# Create a scatterplot
sns.scatterplot,
# Set the alpha
alpha = 0.5,
# Set the edgecolor
edgecolor = 'pink',
# Set the linewidth
linewidth = 1)
# Set the outside plot using the .plot_marginals() function
g.plot_marginals(# Create the histplot
Was alles duidelijk?
Bedankt voor je feedback!
Sectie 5. Hoofdstuk 3
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import warnings
# Ignore all warnings
warnings.filterwarnings('ignore')
# Importing libraries needed
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Reading the file
df = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/66ba0c8e-8422-413c-b7e1-74bd24c61656/penguins_upd.csv')
# Set the 'ticks' style with the 'lightcyan' facecolor
sns.set_style('___', {'figure.facecolor' : '___'})
# Create a JointGrid variable
g = ___(# Set the x
___,
# Set the y
___ = 'bill_depth_mm',
# Set the hue
hue = '___',
# Set the palette
___ = 'viridis',
# Set the data
data = ___)
# Set the inside plot using the .plot_joint() function
___(# Create a scatterplot
sns.___,
# Set the alpha
___ = 0.5,
# Set the edgecolor
___ = 'pink',
# Set the linewidth
___)
# Set the outside plot using the .plot_marginals() function
g.___(# Create the histplot
___,
# Set the kde
___)
# Displaying the plot
plt.show()
Vraag AI
Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.