Plotting
Circumplex Plotting
Plotting functions for visualising circumplex data.
density
density(data=None, x='ISOPleasant', y='ISOEventful', incl_scatter=True, density_type='full', title='Soundscapy Density Plot', diagonal_lines=False, xlim=(-1, 1), ylim=(-1, 1), scatter_kws=dict(s=25, linewidth=0), incl_outline=False, figsize=(5, 5), legend_loc='lower left', alpha=0.75, legend=False, ax=None, hue=None, palette='colorblind', color=None, fill=True, levels=10, thresh=0.05, bw_adjust=None, **kwargs)
Plot a density plot of ISOCoordinates.
Creates a wrapper around seaborn.kdeplot
and adds functionality and styling to customise it for circumplex plots.
The density plot is a combination of a kernel density estimate and a scatter plot.
PARAMETER | DESCRIPTION |
---|---|
color |
DEFAULT:
|
data |
Input data structure. Either a long-form collection of vectors that can be assigned to named variables or a wide-form dataset that will be internally reshaped.
TYPE:
|
x |
Column name for x variable, by default "ISOPleasant"
TYPE:
|
y |
Column name for y variable, by default "ISOEventful"
TYPE:
|
incl_scatter |
Whether to include a scatter plot of the data, by default True
TYPE:
|
density_type |
Type of density plot to draw, by default "full"
TYPE:
|
title |
Title to add to circumplex plot, by default "Soundscapy Density Plot"
TYPE:
|
diagonal_lines |
Whether to include diagonal dimension labels (e.g. calm, etc.), by default False
TYPE:
|
xlim |
Limits of the circumplex plot, by default (-1, 1) It's recommended to set these such that the x and y axes have the same aspect
TYPE:
|
ylim |
Limits of the circumplex plot, by default (-1, 1) It's recommended to set these such that the x and y axes have the same aspect
TYPE:
|
scatter_kws |
Keyword arguments to pass to
TYPE:
|
incl_outline |
TYPE:
|
figsize |
Size of the figure to return if
TYPE:
|
legend_loc |
Relative location of legend, by default "lower left"
TYPE:
|
alpha |
Proportional opacity of the heatmap fill, by default 0.75
TYPE:
|
legend |
If False, suppress the legend for semantic variables, by default True
TYPE:
|
ax |
Pre-existing axes object to use for the plot, by default None
TYPE:
|
hue |
Semantic variable that is mapped to determine the color of plot elements, by default None
TYPE:
|
palette |
Method for choosing the colors to use when mapping the hue semantic. String values are passed to seaborn.color_palette(). List or dict values imply categorical mapping, while a colormap object implies numeric mapping. by default colorblind
TYPE:
|
fill |
If True, fill in the area under univariate density curves or between bivariate contours. If None, the default
depends on
TYPE:
|
levels |
Number of contour levels or values to draw contours at. A vector argument must have increasing values in [0, 1]. Levels correspond to iso-proportionas of the density: e.g. 20% of the probability mass will lie below the contour drawn for 0.2. Only relevant with bivariate data. by default 10
TYPE:
|
thresh |
Lowest iso-proportional level at which to draw a contour line. Ignored when
TYPE:
|
bw_adjust |
Factor that multiplicatively scales the value chosen using
TYPE:
|
**kwargs |
Other keyword arguments are passed to one of the following matplotlib functions:
-
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Axes
|
Axes object containing the plot. |
Source code in soundscapy/plotting/circumplex.py
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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
iso_annotation
iso_annotation(ax, data, location, x_adj=0, y_adj=0, x_key='ISOPleasant', y_key='ISOEventful', ha='center', va='center', fontsize='small', arrowprops=dict(arrowstyle='-', ec='black'), **text_kwargs)
add text annotations to circumplex plot based on coordinate values
Directly uses plt.annotate
PARAMETER | DESCRIPTION |
---|---|
ax |
existing plt axes to add to
TYPE:
|
data |
dataframe of coordinate points
TYPE:
|
location |
name of the coordinate to plot
TYPE:
|
x_adj |
value to adjust x location by, by default 0
TYPE:
|
y_adj |
value to adjust y location by, by default 0
TYPE:
|
x_key |
name of x column, by default "ISOPleasant"
TYPE:
|
y_key |
name of y column, by default "ISOEventful"
TYPE:
|
ha |
horizontal alignment, by default "center"
TYPE:
|
va |
vertical alignment, by default "center"
TYPE:
|
fontsize |
by default "small"
TYPE:
|
arrowprops |
dict of properties to send to plt.annotate, by default dict(arrowstyle="-", ec="black")
TYPE:
|
Example
fig, axes = plt.subplots(1,1, figsize=(5,5)) df_mean.isd.scatter(xlim=(-.5, .5),ylim=(-.5, .5),ax=axes) for location in df_mean.LocationID: plotting.iso_annotation(axes, df_mean, location)
Source code in soundscapy/plotting/circumplex.py
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
|
jointplot
jointplot(data=None, x='ISOPleasant', y='ISOEventful', incl_scatter=True, density_type='full', title='Soundscape Joint Plot', diagonal_lines=False, xlim=(-1, 1), ylim=(-1, 1), scatter_kws=dict(s=25, linewidth=0), incl_outline=False, legend_loc='lower left', alpha=0.75, joint_kws={}, marginal_kws={'fill': True, 'common_norm': False}, hue=None, color=None, palette='colorblind', fill=True, bw_adjust=None, thresh=0.1, levels=10, legend=False, marginal_kind='kde')
Create a jointplot with distribution or scatter in the center and distributions on the margins.
This method works by calling sns.jointplot() and creating a circumplex grid in the joint position, then overlaying a density or circumplex_scatter plot. The options for both the joint and marginal plots can be passed through the sns.jointplot() separately to customise them separately. The marginal distribution plots can be either a density or histogram.
PARAMETER | DESCRIPTION |
---|---|
color |
DEFAULT:
|
data |
Input data structure. Either a long-form collection of vectors that can be assigned to named variables or a wide-form dataset that will be internally reshaped.
TYPE:
|
x |
column name for x variable, by default "ISOPleasant"
TYPE:
|
y |
column name for y variable, by default "ISOEventful"
TYPE:
|
incl_scatter |
Whether to include a scatter plot of the data, by default True
TYPE:
|
density_type |
Type of density plot to draw, by default "full"
TYPE:
|
diagonal_lines |
whether to include diagonal dimension axis labels in the joint plot, by default False
TYPE:
|
palette |
[description], by default "colorblind"
TYPE:
|
incl_scatter |
plot coordinate scatter underneath density plot, by default False
TYPE:
|
fill |
whether to fill the density plot, by default True
TYPE:
|
bw_adjust |
[description], by default default_bw_adjust
TYPE:
|
alpha |
[description], by default 0.95
TYPE:
|
legend |
whether to include the hue labels legend, by default False
TYPE:
|
legend_loc |
relative location of the legend, by default "lower left"
TYPE:
|
marginal_kind |
density or histogram plot in the margins, by default "kde"
TYPE:
|
hue |
Grouping variable that will produce points with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case, by default None
TYPE:
|
joint_kws |
Arguments to pass to density or scatter joint plot, by default {}
TYPE:
|
marginal_kws |
Arguments to pass to marginal distribution plots, by default {"fill": True}
TYPE:
|
hue |
Semantic variable that is mapped to determine the color of plot elements.
TYPE:
|
palette |
Method for choosing the colors to use when mapping the
TYPE:
|
fill |
If True, fill in the area under univariate density curves or between bivariate contours. If None, the default
depends on
TYPE:
|
bw_adjust |
Factor that multiplicatively scales the value chosen using
TYPE:
|
thresh |
Lowest iso-proportional level at which to draw a contour line. Ignored when
TYPE:
|
levels |
Number of contour levels or values to draw contours at. A vector argument must have increasing values in [0, 1]. Levels correspond to iso-proportionas of the density: e.g. 20% of the probability mass will lie below the contour drawn for 0.2. Only relevant with bivariate data. by default 10
TYPE:
|
legend |
If False, suppress the legend for semantic variables, by default False
TYPE:
|
legend_loc |
Relative location of the legend, by default "lower left"
TYPE:
|
marginal_kind |
density or histogram plot in the margins, by default "kde"
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Axes
|
|
Source code in soundscapy/plotting/circumplex.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
|
scatter
scatter(data, x='ISOPleasant', y='ISOEventful', title='Soundscape Scatter Plot', diagonal_lines=False, xlim=(-1, 1), ylim=(-1, 1), figsize=(5, 5), legend_loc='lower left', hue=None, s=20, palette='colorblind', legend='auto', ax=None, **kwargs)
Plot ISOcoordinates as scatter points on a soundscape circumplex grid
PARAMETER | DESCRIPTION |
---|---|
data |
Input data structure. Either a long-form collection of vectors that can be assigned to named variables or a wide-form dataset that will be internally reshaped.
TYPE:
|
x |
column name for x variable, by default "ISOPleasant"
TYPE:
|
y |
column name for y variable, by default "ISOEventful"
TYPE:
|
title |
Title to add to circumplex plot, by default "Soundscape Scatter Plot"
TYPE:
|
diagonal_lines |
whether to include diagonal dimension labels (e.g. calm, etc.), by default False
TYPE:
|
xlim |
Limits of the circumplex plot, by default (-1, 1) It's recommended to set these such that the x and y axes have the same aspect
TYPE:
|
ylim |
Limits of the circumplex plot, by default (-1, 1) It's recommended to set these such that the x and y axes have the same aspect
TYPE:
|
figsize |
Size of the figure to return if
TYPE:
|
legend_loc |
relative location of legend, by default "lower left"
TYPE:
|
hue |
Grouping variable that will produce points with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case, by default None
TYPE:
|
s |
size of scatter points, by default 20
TYPE:
|
palette |
Method for choosing the colors to use when mapping the hue semantic. String values are passed to seaborn.color_palette(). List or dict values imply categorical mapping, while a colormap object implies numeric mapping. by default colorblind
TYPE:
|
legend |
How to draw the legend. If “brief”, numeric hue and size variables will be represented with a sample of evenly spaced values. If “full”, every group will get an entry in the legend. If “auto”, choose between brief or full representation based on number of levels. If False, no legend data is added and no legend is drawn. by default, "auto"
TYPE:
|
ax |
Pre-existing matplotlib axes for the plot, by default None
If
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Axes
|
|
Axes object containing the plot.
|
|
Source code in soundscapy/plotting/circumplex.py
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 55 56 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 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
Likert Scale Plotting
Plotting functions for visualising Likert scale data.
paq_radar_plot
paq_radar_plot(data, ax=None, index=None)
Generate a radar/spider plot of PAQ values
PARAMETER | DESCRIPTION |
---|---|
data |
dataframe of PAQ values recommended max number of values: 3
TYPE:
|
ax |
existing subplot axes to plot to, by default None
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Axes
|
matplotlib Axes with radar plot |
Source code in soundscapy/plotting/likert.py
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
|