bs_seaborn module¶
Some Seaborn plotting utilities:
bs_sns_get_legend
: get theLegend
object of a Seaborn plotbs_sns_bar_x_byf
: make a bar plot ofx
byf
bs_sns_bar_x_byfg
: make a bar plot ofx
byf
andg
bs_sns_plot_density
: basic density plotbs_sns_density_estimates
: plots the densities of estimates of several coefficients with several methods, superposed by methods and faceted by coefficients.
bs_regplot(data, x, y, title=None, line_color='red', save=None)
¶
Draw a seaborn regplot with title and legend.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
DataFrame
|
dataframe, should contain columns |
required |
x |
str
|
column name of x |
required |
y |
str
|
column name of y |
required |
title |
str | None
|
title of plot |
None
|
line_color |
str
|
color of the regression line. Red by default |
'red'
|
save |
str | None
|
where to save it, if requested |
None
|
Returns:
Type | Description |
---|---|
Axes
|
the plot |
Source code in bs_python_utils/bs_seaborn.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
bs_sns_bar_x_byf(df, xstr, fstr, statistic=np.mean, label_x=None, label_f=None, title=None)
¶
Make a bar plot of x
by f
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
dataframe, should contain columns |
required |
xstr |
str
|
column name of x |
required |
fstr |
str
|
column name of f |
required |
statistic |
Callable
|
statistic to plot (by default, the mean) |
mean
|
label_x |
str | None
|
label of x |
None
|
label_f |
str | None
|
label of f |
None
|
title |
str | None
|
title of plot |
None
|
Returns:
Type | Description |
---|---|
Axes
|
the plot. |
Source code in bs_python_utils/bs_seaborn.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
|
bs_sns_bar_x_byfg(df, xstr, fstr, gstr, statistic=np.mean, label_x=None, label_f=None, label_g=None, title=None)
¶
Make a bar plot of x by f and g
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
dataframe, should contain columns |
required |
xstr |
str
|
column name of x |
required |
fstr |
str
|
column name of f |
required |
gstr |
str
|
column name of g |
required |
statistic |
Callable
|
statistic to plot (by default, the mean) |
mean
|
label_x |
str | None
|
label of x |
None
|
label_f |
str | None
|
label of f |
None
|
label_g |
str | None
|
label of g in legend |
None
|
title |
str | None
|
title of plot |
None
|
Returns:
Type | Description |
---|---|
Axes
|
the plot. |
Source code in bs_python_utils/bs_seaborn.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
|
bs_sns_density_estimates(df, true_values, method_string='Estimator', coeff_string='Parameter', estimate_string='Estimate', max_cols=3)
¶
Plots the densities of estimates of several coefficients with several methods, superposed by methods and faceted by coefficients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
contains columns |
required |
true_values |
ndarray
|
the true values of the coefficients |
required |
method_string |
str | None
|
the name of the column that indicates the method |
'Estimator'
|
coeff_string |
str | None
|
the name of the column that indicates the coefficient |
'Parameter'
|
estimate_string |
str | None
|
the name of the column that gives the value of the estimate |
'Estimate'
|
max_cols |
int
|
we wrap after that |
3
|
Returns:
Type | Description |
---|---|
FacetGrid
|
the |
Source code in bs_python_utils/bs_seaborn.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
|
bs_sns_plot_density(df, var_name, save_to=None)
¶
plots the density of a variable
Parameters:
Name | Type | Description | Default |
---|---|---|---|
df |
DataFrame
|
dataframe, should contain column |
required |
var_name |
str
|
the name of a continuous variable |
required |
save_to |
str | None
|
(maybe) where we save the plot, with |
None
|
Source code in bs_python_utils/bs_seaborn.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|