Seaborn Flashcards

(81 cards)

1
Q

How do you plot a scatter graph?

A

sns.lmplot(x = ‘col name’, y = ‘col name’, data = df1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you remove fitting a regression line to a scatter graph?

A

sns.lmplot(fit_reg = False)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you colour in a scatter graph?

A

sns.lmplot(hue = ‘col name’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you get a box and whisker plot?

A

sns.boxplot(data = df1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you get a violin plot?

A

sns.violinplot(x = ‘col’, y = ‘col’, data =df1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you get a swarmplot?

A

sns.swarmplot(x = ‘col’, y = ‘col’, data =df1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you get a scatter plot?

A

sns.scatterplot()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you get a list into a scatter rather than a df?

A

sns.scatterplot(x = listname, y = listname)

vs

sns.scatterplot(x = ‘col name’, y = ‘col name’, data = df)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Do you need a y value for a count plot?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the hues in seaborn code names?

A
Blue = b
Green  = g
Red = r
Cyan = c
Purple = m
Yellow = y
Black = k
White = w
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you change the order in a legend?

A

hue_order = []

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the benefits of relplot over scatter plot?

A

You can show subplots

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you show subplots?

A

relplot

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you get a scatter in a relplot?

A

sns.replot(x = ‘x’, y = ‘y’, data = df, kind = ‘scatter’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you show subplots horiztonally?

A

sns.replot(x = ‘x’, y = ‘y’, data = df, kind = ‘scatter’, rows = ‘variable’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you show subplots vertically?

A

sns.replot(x = ‘x’, y = ‘y’, data = df, kind = ‘scatter’, col = ‘variable’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How do you show subplots both vertically and horiztonally?

A

sns.replot(x = ‘x’, y = ‘y’, data = df, kind = ‘scatter’, col = ‘variable’, row = ‘variable’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How do you limit how many subplots are show in columns at one time?

A

sns.replot(x = ‘x’, y = ‘y’, data = df, kind = ‘scatter’, col = ‘variable’, col_wrap = 2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How do you specify the order of subplots?

A

sns.replot(x = ‘x’, y = ‘y’, data = df, kind = ‘scatter’, col = ‘variable’, col_wrap = 2, col_order = [])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Hue only takes colour inputs?

A

False - you can pass it a categorical variable to colour by type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do you change the marker for categorical variables?

A

style = ‘categorical variable’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

how do you get a line plot

A

sns.relplot(x = , y = , data = , kind = ‘line’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What does a line chart by default show?

A

confidence interval?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How do you change confidence interval to standard deviation?

A

sns.relplot(x = , y =, data =, kind = ‘line’, ci = ‘sd’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What should you use for categorical data?
sns.catplot(x = , y = , data = , kind = 'count' or 'bar')
26
How do you set what order categories come in
order = []
27
How do you turn off confidence intervals
ci = None
28
How do you elimanate outliers from boxplots?
sym = ""
29
How do you change lengths of whiskers in a boxplot?
``` whis = [bottom percentile, top percentile] whis = 2.0 (2 times the IQR) ```
30
How do you generate a boxplot?
sns. boxplot() | sns. catplot(kind = 'box')
31
What is the difference between a point plot and a line plot?
Point plot has one categorical variable, line plot has 2 quantitative variables
32
How do you get a point plot?
kind = 'point'
33
How do you remove the line between points on a point plot?
join = False
34
How do you get a point plot to use median instead of mean/
from numpy import median | estimator = median
35
How do you add a block to the end of the ci of the pointplot?
capsize = x
36
How do you change the style of a plot?
sns.set_style()
37
What are the options under set_style?
``` “white” “dark” “whitegrid” “darkgrid” “ticks” ```
38
How do you change the style of colours?
sns.set_palette()
39
What are options of set_palette?
“RdBu” “PRGn” “RdBu_r”
40
How do you reverse a colour palette?
Add _r at the end of the code eg | “RdBu_r”
41
How do you get sequential palettes?
sns.set_palette(“Greys”)
42
What are the options for sequential colour palettes?
“Greys” “Blues” “PuRd” “GnBu”
43
How do you create a bespoke colour palette?
Custom = [“red”, “green”, “blue”] sns.set_palette(Custom) Or sns.color_palette('Purples',8)
44
How do you change the scale of the plot?
``` sns.set_context() “paper” “notebook” “talk” “poster” ```
45
What is a facetgrid?
An object that contains one or more axes subplots
46
What are the 2 objects that seaborn plots create?
Axes subplot | Facet grid
47
How do you find out what type of object seaborn has created?
g = sns.scatterplot(x = , y = , data = ) | type(g)
48
What objects do relplot and catplot generate?
facetgrid
49
What objects do scatter and boxplot generate?
axes subplot
50
How do you add a title to a facetgrid?
1) give it a variable name | 2) g.fig.suptitle()
51
How do you add a title to an axes subplot?
Assign it to a variable; g | g.set_title()
52
How do you raise the height of the title
g.fig.suptitle(y = 1.5)
53
How do you add a title to a facetgrid that is split by columns / rows?
g. fig.suptitle() for over both | g. set_titles() for the subpltots
54
How do you add axes lables?
g.set(xlabel = , ylabel = ) | Works for both facet grid and axes subplot
55
Is there a difference with how do you set axes labels between facet grid and axes subplots?
No
56
How do you rotate labels?
plt.xticks(rotation = 90)
57
How do you get a histogram in seaborn?
sns.distplot(df['variable'])
58
How do you remove the kde in distplot?
sns.distplot(df['col'], kde = False, bins = 10)
59
How do you get just the kde?
sns.distplot(df['col', hist =False)
60
How do you shade under the kde?
sns.distplot(df['col', hist = False, kde_ksw = {'shade': True})
61
How do you get a regression?
sns. lmplot | sns. regplot
62
Should you use lm plot or reg plot?
lmplot allows arranging data by columns
63
How do you remove axes?
sns.despine(left = True)
64
How do you show a chart with the color palette?
sns.palplot(sns.color_palette('Purples',8))
65
What are the different chart types you can generate using catplot?
``` stripplot() kind = 'strip' swarmplot() kind = 'swarm' boxplot() = kind= 'box' violinplot() kind = 'violin' boxenplot() kind = 'boxen' pointplot() kind = 'point' barplot() kind = 'bar' countplot() kind = 'count' ```
66
What is the difference between a bar plot and a count plot?
Count actually counts, bar averages
67
How do you create bins of categorical data?
sns.regplot(x = , y = , data = , x_bins = )
68
How do you specific which columns to plto in a pairport?
vars or x_vars or y_vars
69
Can you plot different variables on the axes of a pair plot?
Yes x_vars or y_vars
70
How do you change what is plotted on the diagonal of the pairport?
sns.pairplot(diag_kind = )
71
How do you use a training dataset?
sns.load_dataset('')
72
How do you get a chart with histogram on the side?
sns.jointplot(x = , y = , data = )
73
What are the different types of plot in seaborn?
Relational Categorical Distribution Regression
74
What are the types of relational plot?
scatterplot() (with kind="scatter"; the default) | lineplot() (with kind="line")
75
What are the types of categorical plot?
Categorical scatterplots: stripplot() (with kind="strip"; the default) swarmplot() (with kind="swarm") Categorical distribution plots: boxplot() (with kind="box") violinplot() (with kind="violin") boxenplot() (with kind="boxen") Categorical estimate plots: pointplot() (with kind="point") barplot() (with kind="bar") countplot() (with kind="count")
76
What are the types of distribution plot?
The axes-level functions are histplot(), kdeplot(), ecdfplot(), and rugplot().
77
What are the types of regression plot?
These functions, regplot() and lmplot()
78
How do you invoke the generic categorical plot?
Catplot
79
How do you invoke the generic quantitative plot?
relplot
80
How do you invoke the generic distribution?
displot
81
How do you invoke the regressino plot?
lmplot has more flexibility than regplot