Seaborn Flashcards

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
Q

What should you use for categorical data?

A

sns.catplot(x = , y = , data = , kind = ‘count’ or ‘bar’)

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

How do you set what order categories come in

A

order = []

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

How do you turn off confidence intervals

A

ci = None

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

How do you elimanate outliers from boxplots?

A

sym = “”

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

How do you change lengths of whiskers in a boxplot?

A
whis = [bottom percentile, top percentile]
whis = 2.0 (2 times the IQR)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
30
Q

How do you generate a boxplot?

A

sns. boxplot()

sns. catplot(kind = ‘box’)

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

What is the difference between a point plot and a line plot?

A

Point plot has one categorical variable, line plot has 2 quantitative variables

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

How do you get a point plot?

A

kind = ‘point’

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

How do you remove the line between points on a point plot?

A

join = False

34
Q

How do you get a point plot to use median instead of mean/

A

from numpy import median

estimator = median

35
Q

How do you add a block to the end of the ci of the pointplot?

A

capsize = x

36
Q

How do you change the style of a plot?

A

sns.set_style()

37
Q

What are the options under set_style?

A
“white”
“dark”
“whitegrid”
“darkgrid”
“ticks”
38
Q

How do you change the style of colours?

A

sns.set_palette()

39
Q

What are options of set_palette?

A

“RdBu”
“PRGn”
“RdBu_r”

40
Q

How do you reverse a colour palette?

A

Add _r at the end of the code eg

“RdBu_r”

41
Q

How do you get sequential palettes?

A

sns.set_palette(“Greys”)

42
Q

What are the options for sequential colour palettes?

A

“Greys”
“Blues”
“PuRd”
“GnBu”

43
Q

How do you create a bespoke colour palette?

A

Custom = [“red”, “green”, “blue”]
sns.set_palette(Custom)

Or

sns.color_palette(‘Purples’,8)

44
Q

How do you change the scale of the plot?

A
sns.set_context()
“paper”
“notebook”
“talk”
“poster”
45
Q

What is a facetgrid?

A

An object that contains one or more axes subplots

46
Q

What are the 2 objects that seaborn plots create?

A

Axes subplot

Facet grid

47
Q

How do you find out what type of object seaborn has created?

A

g = sns.scatterplot(x = , y = , data = )

type(g)

48
Q

What objects do relplot and catplot generate?

A

facetgrid

49
Q

What objects do scatter and boxplot generate?

A

axes subplot

50
Q

How do you add a title to a facetgrid?

A

1) give it a variable name

2) g.fig.suptitle()

51
Q

How do you add a title to an axes subplot?

A

Assign it to a variable; g

g.set_title()

52
Q

How do you raise the height of the title

A

g.fig.suptitle(y = 1.5)

53
Q

How do you add a title to a facetgrid that is split by columns / rows?

A

g. fig.suptitle() for over both

g. set_titles() for the subpltots

54
Q

How do you add axes lables?

A

g.set(xlabel = , ylabel = )

Works for both facet grid and axes subplot

55
Q

Is there a difference with how do you set axes labels between facet grid and axes subplots?

A

No

56
Q

How do you rotate labels?

A

plt.xticks(rotation = 90)

57
Q

How do you get a histogram in seaborn?

A

sns.distplot(df[‘variable’])

58
Q

How do you remove the kde in distplot?

A

sns.distplot(df[‘col’], kde = False, bins = 10)

59
Q

How do you get just the kde?

A

sns.distplot(df[‘col’, hist =False)

60
Q

How do you shade under the kde?

A

sns.distplot(df[‘col’, hist = False, kde_ksw = {‘shade’: True})

61
Q

How do you get a regression?

A

sns. lmplot

sns. regplot

62
Q

Should you use lm plot or reg plot?

A

lmplot allows arranging data by columns

63
Q

How do you remove axes?

A

sns.despine(left = True)

64
Q

How do you show a chart with the color palette?

A

sns.palplot(sns.color_palette(‘Purples’,8))

65
Q

What are the different chart types you can generate using catplot?

A
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
Q

What is the difference between a bar plot and a count plot?

A

Count actually counts, bar averages

67
Q

How do you create bins of categorical data?

A

sns.regplot(x = , y = , data = , x_bins = )

68
Q

How do you specific which columns to plto in a pairport?

A

vars or x_vars or y_vars

69
Q

Can you plot different variables on the axes of a pair plot?

A

Yes x_vars or y_vars

70
Q

How do you change what is plotted on the diagonal of the pairport?

A

sns.pairplot(diag_kind = )

71
Q

How do you use a training dataset?

A

sns.load_dataset(‘’)

72
Q

How do you get a chart with histogram on the side?

A

sns.jointplot(x = , y = , data = )

73
Q

What are the different types of plot in seaborn?

A

Relational
Categorical
Distribution
Regression

74
Q

What are the types of relational plot?

A

scatterplot() (with kind=”scatter”; the default)

lineplot() (with kind=”line”)

75
Q

What are the types of categorical plot?

A

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
Q

What are the types of distribution plot?

A

The axes-level functions are histplot(), kdeplot(), ecdfplot(), and rugplot().

77
Q

What are the types of regression plot?

A

These functions, regplot() and lmplot()

78
Q

How do you invoke the generic categorical plot?

A

Catplot

79
Q

How do you invoke the generic quantitative plot?

A

relplot

80
Q

How do you invoke the generic distribution?

A

displot

81
Q

How do you invoke the regressino plot?

A

lmplot has more flexibility than regplot