Regplot
The regplot
is used to plot data and a linear regression model fit. There are a number of mutually exclusive options for estimating the regression model.









Oppgave
Swipe to start coding
- Set the
'darkgrid'
style with the'tan'
figure facecolor and'cornsilk'
axes .facecolor
. - Create a
regplot
using theseaborn
library:
- Set the
x
parameter equals the'total_bill'
; - Set the
y
parameter equals the'tip'
; - Set the
marker
parameter equals the'+'
; - Set the
'green'
color
; - Disable the
fit_reg
parameter; - Set the data;
- Display the plot.
Løsning
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
# 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/tips.csv')
# Set the 'darkgrid' style with the 'tan' figure facecolor and 'cornsilk' axes facecolor
sns.set_style('darkgrid',
{'figure.facecolor' : 'tan',
'axes.facecolor' : 'cornsilk'})
# Create a regplot
sns.regplot(# Set the x
x = 'total_bill',
# Set the y
y = 'tip',
# Set the marker
marker = '+',
# Set the color
color = 'green',
# Disable the fit_reg
fit_reg = False,
# Set the data
data = df)
# Display the data
plt.show()
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 6. Kapittel 1
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
# 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/tips.csv')
# Set the 'darkgrid' style with the 'tan' figure facecolor and 'cornsilk' axes facecolor
sns.set_style('___',
{'figure.___' : '___',
'___' : '___'})
# Create a regplot
___(# Set the x
___,
# Set the y
y = '___',
# Set the marker
___ = '+',
# Set the color
___,
# Disable the fit_reg
fit_reg = ___,
# Set the data
___)
# Display the data
___
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår