Plotting
Utility functions for creating various types of circumplex plots.
create_circumplex_subplots
create_circumplex_subplots(data_list, plot_type=PlotType.DENSITY, incl_scatter=True, subtitles=None, title='Circumplex Subplots', nrows=None, ncols=None, figsize=(10, 10), **kwargs)
Create a figure with subplots containing circumplex plots.
RETURNS | DESCRIPTION |
---|---|
matplotlib.figure.Figure: A figure containing the subplots.
|
|
Example
>>> import pandas as pd
>>> import numpy as np
>>> np.random.seed(42)
>>> data1 = pd.DataFrame({'ISOPleasant': np.random.uniform(-1, 1, 50),
... 'ISOEventful': np.random.uniform(-1, 1, 50)})
>>> data2 = pd.DataFrame({'ISOPleasant': np.random.uniform(-1, 1, 50),
... 'ISOEventful': np.random.uniform(-1, 1, 50)})
>>> fig = create_circumplex_subplots([data1, data2], plot_type=PlotType.SCATTER, nrows=1, ncols=2)
>>> isinstance(fig, plt.Figure)
True
Source code in soundscapy/plotting/plot_functions.py
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 285 286 287 288 289 |
|
density_plot
density_plot(data, x='ISOPleasant', y='ISOEventful', hue=None, title='Soundscape Density Plot', xlim=DEFAULT_XLIM, ylim=DEFAULT_YLIM, palette='colorblind', fill=True, incl_outline=False, incl_scatter=True, diagonal_lines=False, show_labels=True, legend=True, legend_location='best', backend=Backend.SEABORN, apply_styling=True, figsize=DEFAULT_FIGSIZE, simple_density=False, simple_density_thresh=0.5, simple_density_levels=2, simple_density_alpha=0.5, ax=None, extra_params={}, **kwargs)
Create a density plot using the CircumplexPlot class.
RETURNS | DESCRIPTION |
---|---|
plt.Axes | go.Figure: The resulting plot object.
|
|
Source code in soundscapy/plotting/plot_functions.py
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 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 |
|
scatter_plot
scatter_plot(data, x='ISOPleasant', y='ISOEventful', hue=None, title='Soundscape Scatter Plot', xlim=DEFAULT_XLIM, ylim=DEFAULT_YLIM, palette='colorblind', diagonal_lines=False, show_labels=True, legend=True, legend_location='best', backend=Backend.SEABORN, apply_styling=True, figsize=DEFAULT_FIGSIZE, ax=None, extra_params={}, **kwargs)
Create a scatter plot using the CircumplexPlot class.
RETURNS | DESCRIPTION |
---|---|
plt.Axes | go.Figure: The resulting plot object.
|
|
Source code in soundscapy/plotting/plot_functions.py
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 |
|
Circumplex Plotting
Main module for creating circumplex plots using different backends.
CircumplexPlot
CircumplexPlot(data, params=CircumplexPlotParams(), backend=Backend.SEABORN, style_options=StyleOptions())
A class for creating circumplex plots using different backends.
This class provides methods for creating scatter plots and density plots based on the circumplex model of soundscape perception. It supports multiple backends (currently Seaborn and Plotly) and offers various customization options.
Source code in soundscapy/plotting/circumplex_plot.py
62 63 64 65 66 67 68 69 70 71 72 73 |
|
density
density(apply_styling=True, ax=None)
Create a density plot.
Source code in soundscapy/plotting/circumplex_plot.py
125 126 127 128 129 |
|
get_axes
get_axes()
Get the axes object of the plot (only for Seaborn backend).
Source code in soundscapy/plotting/circumplex_plot.py
153 154 155 156 157 158 159 160 161 162 |
|
get_figure
get_figure()
Get the figure object of the plot.
Source code in soundscapy/plotting/circumplex_plot.py
145 146 147 148 149 150 151 |
|
get_style_options
get_style_options()
Get the current StyleOptions.
Source code in soundscapy/plotting/circumplex_plot.py
164 165 166 |
|
iso_annotation
iso_annotation(location, x_adj=0, y_adj=0, **kwargs)
Add an annotation to the plot (only for Seaborn backend).
Source code in soundscapy/plotting/circumplex_plot.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
|
scatter
scatter(apply_styling=True, ax=None)
Create a scatter plot.
Source code in soundscapy/plotting/circumplex_plot.py
119 120 121 122 123 |
|
show
show()
Display the plot.
Source code in soundscapy/plotting/circumplex_plot.py
137 138 139 140 141 142 143 |
|
simple_density
simple_density(apply_styling=True, ax=None)
Create a simple density plot.
Source code in soundscapy/plotting/circumplex_plot.py
131 132 133 134 135 |
|
update_style_options
update_style_options(**kwargs)
Update the StyleOptions with new values.
Source code in soundscapy/plotting/circumplex_plot.py
168 169 170 171 172 173 174 175 176 177 178 179 |
|
CircumplexPlotParams
dataclass
CircumplexPlotParams(x='ISOPleasant', y='ISOEventful', hue=None, title='Soundscape Plot', xlim=DEFAULT_XLIM, ylim=DEFAULT_YLIM, alpha=0.8, fill=True, palette=None, incl_outline=False, diagonal_lines=False, show_labels=True, legend='auto', legend_location='best', extra_params=dict())
Parameters for customizing CircumplexPlot.
Backends
PlotBackend
Bases: ABC
Abstract base class for plot backends.
This class defines the interface for creating scatter and density plots, as well as applying styling to the plots.
apply_styling
abstractmethod
apply_styling(plot_obj, params)
Apply styling to the plot.
RETURNS | DESCRIPTION |
---|---|
The styled plot object.
|
|
Source code in soundscapy/plotting/backends.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
create_density
abstractmethod
create_density(data, params)
Create a density plot.
RETURNS | DESCRIPTION |
---|---|
The created plot object.
|
|
Source code in soundscapy/plotting/backends.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
create_scatter
abstractmethod
create_scatter(data, params)
Create a scatter plot.
RETURNS | DESCRIPTION |
---|---|
The created plot object.
|
|
Source code in soundscapy/plotting/backends.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
PlotlyBackend
PlotlyBackend()
Bases: PlotBackend
Backend for creating plots using Plotly.
Source code in soundscapy/plotting/backends.py
245 246 247 248 249 |
|
apply_styling
apply_styling(plot_obj, params)
Apply styling to the Plotly plot.
RETURNS | DESCRIPTION |
---|---|
go.Figure: The styled Plotly figure object.
|
|
Source code in soundscapy/plotting/backends.py
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 |
|
create_density
create_density(data, params)
Create a density plot using Plotly.
RETURNS | DESCRIPTION |
---|---|
go.Figure: A Plotly figure object.
|
|
Source code in soundscapy/plotting/backends.py
282 283 284 285 286 287 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 |
|
create_scatter
create_scatter(data, params)
Create a scatter plot using Plotly.
RETURNS | DESCRIPTION |
---|---|
go.Figure: A Plotly figure object.
|
|
Source code in soundscapy/plotting/backends.py
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 |
|
show
show(fig)
Display the Plotly figure.
Source code in soundscapy/plotting/backends.py
357 358 359 360 361 362 363 364 365 |
|
SeabornBackend
SeabornBackend(style_options=StyleOptions())
Bases: PlotBackend
Backend for creating plots using Seaborn and Matplotlib.
Source code in soundscapy/plotting/backends.py
74 75 |
|
apply_styling
apply_styling(plot_obj, params)
Apply styling to the Seaborn plot.
RETURNS | DESCRIPTION |
---|---|
tuple: The styled figure and axes objects.
|
|
Source code in soundscapy/plotting/backends.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
|
create_density
create_density(data, params, ax=None)
Create a density plot using Seaborn.
RETURNS | DESCRIPTION |
---|---|
tuple: A tuple containing the figure and axes objects.
|
|
Source code in soundscapy/plotting/backends.py
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 |
|
create_scatter
create_scatter(data, params, ax=None)
Create a scatter plot using Seaborn.
RETURNS | DESCRIPTION |
---|---|
tuple: A tuple containing the figure and axes objects.
|
|
Source code in soundscapy/plotting/backends.py
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 111 112 |
|
show
show(plot_obj)
Display the Matplotlib figure.
Source code in soundscapy/plotting/backends.py
228 229 230 231 232 233 234 235 236 237 |
|
Stylers
Styling utilities for circumplex plots using Seaborn and Matplotlib.
SeabornStyler
SeabornStyler(params, style_options=StyleOptions())
Class for applying Seaborn styles to circumplex plots.
Source code in soundscapy/plotting/stylers.py
50 51 52 |
|
apply_styling
apply_styling(fig, ax)
Apply styling to the plot.
RETURNS | DESCRIPTION |
---|---|
Tuple[mpl.figure.Figure, mpl.axes.Axes]: The styled figure and axes.
|
|
Source code in soundscapy/plotting/stylers.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
circumplex_grid
circumplex_grid(ax)
Add the circumplex grid to the plot.
Source code in soundscapy/plotting/stylers.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
deal_w_default_labels
deal_w_default_labels(ax)
Handle the default labels for the axes.
Source code in soundscapy/plotting/stylers.py
109 110 111 112 113 114 115 116 |
|
diagonal_lines_and_labels
diagonal_lines_and_labels(ax)
Add diagonal lines and labels to the plot.
Source code in soundscapy/plotting/stylers.py
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 |
|
move_legend
move_legend(ax)
Move the legend to the specified location.
Source code in soundscapy/plotting/stylers.py
118 119 120 121 122 123 124 |
|
primary_lines_and_labels
primary_lines_and_labels(ax)
Add primary lines to the plot.
Source code in soundscapy/plotting/stylers.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
set_circum_title
set_circum_title(ax)
Set the title for the circumplex plot.
Source code in soundscapy/plotting/stylers.py
104 105 106 107 |
|
set_style
set_style()
Set the overall style for the plot.
Source code in soundscapy/plotting/stylers.py
77 78 79 |
|
StyleOptions
dataclass
StyleOptions(diag_lines_zorder=1, diag_labels_zorder=4, prim_lines_zorder=2, data_zorder=3, bw_adjust=1.2, figsize=DEFAULT_FIGSIZE, simple_density=lambda: {'thresh': 0.5, 'levels': 2, 'incl_outline': True, 'alpha': 0.5}())
Configuration options for styling circumplex plots.
Attributes: diag_lines_zorder (int): Z-order for diagonal lines. diag_labels_zorder (int): Z-order for diagonal labels. prim_lines_zorder (int): Z-order for primary lines. data_zorder (int): Z-order for plotted data. bw_adjust (float): Bandwidth adjustment for kernel density estimation. figsize (Tuple[int, int]): Figure size (width, height) in inches. simple_density (Dict[str, Any]): Configuration for simple density plots.
Plotting Utilities
Utility functions and constants for the soundscapy plotting module.
Backend
Bases: Enum
Enum for supported plotting backends.
ExtraParams
Bases: TypedDict
TypedDict for extra parameters passed to plotting functions.
PlotType
Bases: Enum
Enum for supported plot types.
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
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 74 |
|