Plot Functions¶
soundscapy.plotting.plot_functions
¶
Plotting functions for visualizing circumplex data.
| FUNCTION | DESCRIPTION |
|---|---|
iso_plot |
Plot a soundscape visualization based on the specified metrics using different |
create_iso_subplots |
Create a set of subplots displaying data visualizations for soundscape analysis. |
allocate_subplot_axes |
Allocate the subplot axes based on the number of data subsets. |
scatter |
Plot ISOcoordinates as scatter points on a soundscape circumplex grid. |
density |
Plot a density plot of ISOCoordinates. |
create_circumplex_subplots |
Create a figure with subplots containing circumplex plots. |
jointplot |
Create a jointplot with a central distribution and marginal plots. |
iso_annotation |
Add text annotations to circumplex plot based on coordinate values. |
scatter_plot |
Wrapper for the scatter function to maintain backwards compatibility. |
density_plot |
Wrapper for the density function to maintain backwards compatibility. |
iso_plot
¶
iso_plot(
data: DataFrame,
x: str = "ISOPleasant",
y: str = "ISOEventful",
title: str | None = "Soundscapy Plot",
plot_layers: Literal[
"scatter", "density", "simple_density"
]
| Sequence[
Literal["scatter", "density", "simple_density"]
] = ("scatter", "density"),
**kwargs,
) -> Axes
Plot a soundscape visualization based on the specified metrics using different combinations of layers such as scatter, density, or simple density plots.
The function generates a 2D plot (via Matplotlib Axes object) based on the x and
y metrics provided. Users can choose between individual layers or specify a
combination of the supported plot layers. It supports automatic handling for
specific layer combinations, such as "scatter + density". The core plotting
functionality is delegated to other helper functions (scatter and density).
| PARAMETER | DESCRIPTION |
|---|---|
data
|
The dataset containing the metrics to be plotted. Must include the columns
specified for
TYPE:
|
x
|
The column name within
TYPE:
|
y
|
The column name within
TYPE:
|
title
|
The title of the plot. If not specified, defaults to "Soundscapy Plot".
TYPE:
|
plot_layers
|
Specifies the type or combination of plot layers to generate. Valid options include:
Can be passed as a string (single layer) or as a sequence of strings (combination of layers). Defaults to ("scatter", "density").
TYPE:
|
**kwargs
|
Additional keyword arguments to be passed to the underlying plotting
functions (
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Axes
|
A Matplotlib Axes object corresponding to the generated plot. |
Notes
This function supports only specific combinations of layers. If an unsupported combination is specified, an exception will be raised. Layer compatibility rules:
- Single layers: "scatter", "density", or "simple_density".
- Dual layers:
- "scatter" + "density"
- "scatter" + "simple_density"
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the |
ValueError
|
If the |
Examples:
Basic density and scatter plot with default settings:
>>> import soundscapy as sspy
>>> import matplotlib.pyplot as plt
>>> data = sspy.isd.load()
>>> data = sspy.add_iso_coords(data)
>>> ax = sspy.iso_plot(data)
>>> plt.show()
Basic scatter plot:
Simple density plot with fewer contour levels:
Simple density with scatter points
Density plot with custom styling:
>>> sub_data = sspy.isd.select_location_ids(
... data, ['CamdenTown', 'PancrasLock', 'RegentsParkJapan', 'RegentsParkFields'])
>>> ax = sspy.iso_plot(
... sub_data,
... hue="SessionID",
... plot_layers = ["scatter", "simple_density"],
... legend_loc="upper right",
... fill = False,
... )
>>> plt.show()
Add density to existing plots:
>>> fig, axes = plt.subplots(1, 2, figsize=(12, 6))
>>> axes[0] = sspy.iso_plot(
... sspy.isd.select_location_ids(data, ['CamdenTown', 'PancrasLock']),
... ax=axes.flatten()[0], title="CamdenTown and PancrasLock", hue="LocationID",
... )
>>> axes[1] = sspy.iso_plot(
... sspy.isd.select_location_ids(data, ['RegentsParkJapan']),
... ax=axes.flatten()[1], title="RegentsParkJapan"
... )
>>> plt.tight_layout()
>>> plt.show()
>>> plt.close('all')
Source code in src/soundscapy/plotting/plot_functions.py
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 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 | |
create_iso_subplots
¶
create_iso_subplots(
data: DataFrame | list[DataFrame],
x: str = "ISOPleasant",
y: str = "ISOEventful",
subplot_by: str | None = None,
title: str | None = "Soundscapy Plot",
plot_layers: Literal[
"scatter", "density", "simple_density"
]
| Sequence[
Literal["scatter", "simple_density", "density"]
] = ("scatter", "density"),
*,
subplot_size: tuple[int, int] = (4, 4),
subplot_titles: Literal["by_group", "numbered"]
| list[str]
| None = "by_group",
subplot_title_prefix: str = "Plot",
nrows: int | None = None,
ncols: int | None = None,
**kwargs,
) -> tuple[Figure, np.ndarray]
Create a set of subplots displaying data visualizations for soundscape analysis.
This function generates a collection of subplots, where each subplot corresponds to a subset of the input data. The subplots can display scatter plots, density plots, or simplified density plots, and can be organized by specific grouping criteria. Users can specify titles, overall size, row and column layout, and layering of plot types.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Input data to be visualized. Can be a single data frame or a list of data frames for use in multiple subplots.
TYPE:
|
x
|
The name of the column in the data to be used for the x-axis. Default is "ISOPleasant".
TYPE:
|
y
|
The name of the column in the data to be used for the y-axis. Default is "ISOEventful".
TYPE:
|
subplot_by
|
The column name by which to group data into subplots. If None, data is not grouped and plotted in a single set of axes. Default is None.
TYPE:
|
title
|
The overarching title of the figure. If None, no overall title is added. Default is "Soundscapy Plot".
TYPE:
|
plot_layers
|
Type(s) of plot layers to include in each subplot. Can be a single type or a sequence of types. Default is ("scatter", "density").
TYPE:
|
subplot_size
|
Size of each subplot in inches as (width, height). Default is (4, 4). |
subplot_titles
|
Determines how subplot titles are assigned. Options are "by_group" (titles derived from group names), "numbered" (titles as indices), or a list of custom titles. If None, no titles are added. Default is "by_group".
TYPE:
|
subplot_title_prefix
|
Prefix for subplot titles if "numbered" is selected as
TYPE:
|
nrows
|
Number of rows for the subplot grid. If None, automatically calculated based on the number of subplots. Default is None.
TYPE:
|
ncols
|
Number of columns for the subplot grid. If None, automatically calculated based on the number of subplots. Default is None.
TYPE:
|
**kwargs
|
Additional keyword arguments to pass to matplotlib's
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[Figure, ndarray]
|
A tuple containing:
|
Examples:
Basic subplots with default settings:
>>> import soundscapy as sspy
>>> import matplotlib.pyplot as plt
>>> import pandas as pd
>>> data = sspy.isd.load()
>>> data = sspy.add_iso_coords(data)
>>> four_locs = sspy.isd.select_location_ids(data,
... ['CamdenTown', 'PancrasLock', 'RegentsParkJapan', 'RegentsParkFields']
... )
>>> fig, axes = sspy.create_iso_subplots(four_locs, subplot_by="LocationID")
>>> plt.show()
Create subplots by specifying a list of data
>>> 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, axes = create_iso_subplots(
... [data1, data2], plot_layers="scatter", nrows=1, ncols=2
... )
>>> plt.show()
>>> assert len(axes) == 2
>>> plt.close('all')
Source code in src/soundscapy/plotting/plot_functions.py
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 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 | |
allocate_subplot_axes
¶
allocate_subplot_axes(
nrows: int | None, ncols: int | None, n_subplots: int
) -> tuple[int, int, int]
Allocate the subplot axes based on the number of data subsets.
| PARAMETER | DESCRIPTION |
|---|---|
nrows
|
Number of rows for subplots. Can be None to auto-determine.
TYPE:
|
ncols
|
Number of columns for subplots. Can be None to auto-determine.
TYPE:
|
n_subplots
|
Total number of subplots needed.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[int, int, int]
|
The number of rows and columns for the subplot grid. |
Notes
Logic for determining subplot layout:
- If both nrows and ncols are specified, use those values
- If both are None, calculate a grid as close to square as possible
- If only one is specified, calculate the other to fit all subplots
Source code in src/soundscapy/plotting/plot_functions.py
scatter
¶
scatter(
data: DataFrame,
title: str | None = "Soundscape Scatter Plot",
ax: Axes | None = None,
*,
x: str | None = "ISOPleasant",
y: str | None = "ISOEventful",
hue: str | None = None,
palette: SeabornPaletteType | None = "colorblind",
legend: Literal[
"auto", "brief", "full", False
] = "auto",
prim_labels: bool | None = None,
**kwargs,
) -> Axes
Plot ISOcoordinates as scatter points on a soundscape circumplex grid.
Creates a scatter plot of data on a standardized circumplex grid with the custom Soundscapy styling for soundscape circumplex visualisations.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Input data structure containing coordinate data, typically with ISOPleasant and ISOEventful columns.
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:
|
ax
|
Pre-existing matplotlib axes for the plot, by default None
If
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:
|
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:
|
prim_labels
|
Deprecated. Use xlabel and ylabel parameters instead.
TYPE:
|
**kwargs
|
Additional style arguments. Common options include
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Axes
|
Axes object containing the plot. |
Notes
This function applies special styling appropriate for circumplex plots including gridlines, axis labels, and proportional axes.
Examples:
Basic scatter plot with default settings:
>>> import soundscapy as sspy
>>> import matplotlib.pyplot as plt
>>> data = sspy.isd.load()
>>> data = sspy.add_iso_coords(data)
>>> ax = sspy.scatter(data)
>>> plt.show()
Scatter plot with grouping by location:
>>> ax = sspy.scatter(data, hue="LocationID", diagonal_lines=True, legend=False)
>>> plt.show()
>>> plt.close('all')
Source code in src/soundscapy/plotting/plot_functions.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 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 | |
density
¶
density(
data: DataFrame,
title: str | None = "Soundscape Density Plot",
ax: Axes | None = None,
*,
x: str | None = "ISOPleasant",
y: str | None = "ISOEventful",
hue: str | None = None,
incl_scatter: bool = True,
density_type: str = "full",
palette: SeabornPaletteType | None = "colorblind",
scatter_kws: dict | None = None,
legend: Literal[
"auto", "brief", "full", False
] = "auto",
prim_labels: bool | None = None,
**kwargs,
) -> Axes
Plot a density plot of ISOCoordinates.
Creates a kernel density estimate visualization of data distribution on a circumplex grid with the custom Soundscapy styling for soundscape circumplex visualisations. Can optionally include a scatter plot of the underlying data points.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Input data structure containing coordinate data, typically with ISOPleasant and ISOEventful columns.
TYPE:
|
title
|
Title to add to circumplex plot, by default "Soundscape Density Plot"
TYPE:
|
ax
|
Pre-existing axes object to use for the plot, by default None
If
TYPE:
|
x
|
Column name for x variable, by default "ISOPleasant"
TYPE:
|
y
|
Column name for y variable, by default "ISOEventful"
TYPE:
|
hue
|
Grouping variable that will produce density contours with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case, by default None
TYPE:
|
incl_scatter
|
Whether to include a scatter plot of the data points, by default True
TYPE:
|
density_type
|
Type of density plot to draw. "full" uses default parameters, "simple" uses a lower number of levels (2), higher threshold (0.5), and lower alpha (0.5) for a cleaner visualization, by default "full"
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:
|
scatter_kws
|
Keyword arguments to pass to
TYPE:
|
legend
|
How to draw the legend. If "brief", numeric hue 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:
|
prim_labels
|
Deprecated. Use xlabel and ylabel parameters instead.
TYPE:
|
**kwargs
|
Additional styling parameters. Common options include
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Axes
|
Axes object containing the plot. |
Notes
This function will raise a warning if the dataset has fewer than RECOMMENDED_MIN_SAMPLES (30) data points, as density plots are not reliable with small sample sizes.
Examples:
Basic density plot with default settings:
>>> import soundscapy as sspy
>>> import matplotlib.pyplot as plt
>>> data = sspy.isd.load()
>>> data = sspy.add_iso_coords(data)
>>> ax = sspy.density(data)
>>> plt.show()
Simple density plot with fewer contour levels:
Density plot with custom styling:
>>> sub_data = sspy.isd.select_location_ids(
... data, ['CamdenTown', 'PancrasLock', 'RegentsParkJapan', 'RegentsParkFields'])
>>> ax = sspy.density(
... sub_data,
... hue="SessionID",
... incl_scatter=True,
... legend_loc="upper right",
... fill = False,
... density_type = "simple",
... )
>>> plt.show()
Add density to existing plots:
>>> fig, axes = plt.subplots(1, 2, figsize=(12, 6))
>>> axes[0] = sspy.density(
... sspy.isd.select_location_ids(data, ['CamdenTown', 'PancrasLock']),
... ax=axes[0], title="CamdenTown and PancrasLock", hue="LocationID",
... density_type="simple"
... )
>>> axes[1] = sspy.density(
... sspy.isd.select_location_ids(data, ['RegentsParkJapan']),
... ax=axes[1], title="RegentsParkJapan"
... )
>>> plt.tight_layout()
>>> plt.show()
>>> plt.close('all')
Source code in src/soundscapy/plotting/plot_functions.py
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 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 | |
create_circumplex_subplots
¶
create_circumplex_subplots(
data_list: list[DataFrame],
plot_type: Literal[
"density", "scatter", "simple_density"
] = "density",
incl_scatter: bool = True,
subtitles: list[str] | None = None,
title: str = "Circumplex Subplots",
nrows: int | None = None,
ncols: int | None = None,
figsize: tuple[int, int] = (10, 10),
**kwargs: Any,
) -> Figure
Create a figure with subplots containing circumplex plots.
Deprecated v0.8.0
Use :func:create_iso_subplots instead.
| PARAMETER | DESCRIPTION |
|---|---|
data_list
|
A list of pandas DataFrames, each containing the data for one subplot.
TYPE:
|
plot_type
|
Type of plot to create in each subplot. Options are "scatter", "density",
TYPE:
|
incl_scatter
|
Whether to include scatter points in density plots. Only applies if plot_type is "density" or "simple_density". By default, True.
TYPE:
|
subtitles
|
A list of titles for each subplot. If None, no titles will be added to subplots. If "numbered", subplots will be titled "Plot 1", "Plot 2", etc. Default is None. |
title
|
Title for the entire figure, by default "Circumplex Subplots"
TYPE:
|
nrows
|
Number of rows in the subplot grid. If None, it will be automatically determined based on the number of subplots and ncols. Default is None.
TYPE:
|
ncols
|
Number of columns in the subplot grid. If None, it will be automatically determined based on the number of subplots and nrows. Default is None.
TYPE:
|
figsize
|
Size of the entire figure, by default (10, 10) |
**kwargs
|
Additional keyword arguments to pass to the underlying plotting functions. For scatter plots, accepts any parameters from seaborn.scatterplot. For density plots, accepts any parameters from seaborn.kdeplot. Also accepts style parameters for the circumplex plots such as xlim, ylim, xlabel, ylabel, diagonal_lines, legend_loc, and prim_ax_fontdict.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Figure
|
A matplotlib Figure object containing the created subplots. |
Example
import pandas as pd import numpy as np import matplotlib.pyplot as plt 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="scatter", nrows=1, ncols=2 ... ) plt.show() # doctest: +SKIP isinstance(fig, plt.Figure) True plt.close('all')
Source code in src/soundscapy/plotting/plot_functions.py
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 | |
jointplot
¶
jointplot(
data: DataFrame,
*,
x: str = DEFAULT_XCOL,
y: str = DEFAULT_YCOL,
title: str | None = "Soundscape Joint Plot",
hue: str | None = None,
incl_scatter: bool = True,
density_type: str = "full",
palette: SeabornPaletteType | None = "colorblind",
color: ColorType | None = DEFAULT_COLOR,
scatter_kws: dict[str, Any] | None = None,
incl_outline: bool = False,
alpha: float = DEFAULT_SEABORN_PARAMS["alpha"],
fill: bool = True,
levels: int | tuple[float, ...] = 10,
thresh: float = 0.05,
bw_adjust: float = DEFAULT_BW_ADJUST,
legend: Literal[
"auto", "brief", "full", False
] = "auto",
prim_labels: bool | None = None,
joint_kws: dict[str, Any] | None = None,
marginal_kws: dict[str, Any] | None = None,
marginal_kind: str = "kde",
**kwargs,
) -> sns.JointGrid
Create a jointplot with a central distribution and marginal plots.
Creates a visualization with a main plot (density or scatter) in the center and marginal distribution plots along the x and y axes. The main plot uses the custom Soundscapy styling for soundscape circumplex visualisations, and the marginals show the individual distributions of each variable.
| PARAMETER | DESCRIPTION |
|---|---|
data
|
Input data structure containing coordinate data, typically with ISOPleasant and ISOEventful columns.
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 the jointplot, by default "Soundscape Joint Plot"
TYPE:
|
hue
|
Grouping variable that will produce plots with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case, by default None
TYPE:
|
incl_scatter
|
Whether to include a scatter plot of the data points in the joint plot, by default True
TYPE:
|
density_type
|
Type of density plot to draw. "full" uses default parameters, "simple" uses a lower number of levels (2), higher threshold (0.5), and lower alpha (0.5) for a cleaner visualization, by default "full"
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:
|
scatter_kws
|
Additional keyword arguments to pass to scatter plot if incl_scatter is True, by default None |
incl_outline
|
Whether to include an outline for the density contours, by default False
TYPE:
|
alpha
|
Opacity level for the density fill, by default 0.8
TYPE:
|
fill
|
Whether to fill the density contours, by default True
TYPE:
|
levels
|
Number of contour levels or specific levels to draw. A vector argument must have increasing values in [0, 1], by default 10 |
thresh
|
Lowest iso-proportion level at which to draw contours, by default 0.05
TYPE:
|
bw_adjust
|
Factor that multiplicatively scales the bandwidth. Increasing will make the density estimate smoother, by default 1.2
TYPE:
|
legend
|
How to draw the legend for hue mapping, by default "auto"
TYPE:
|
prim_labels
|
Deprecated. Use xlabel and ylabel parameters instead.
TYPE:
|
joint_kws
|
Additional keyword arguments to pass to the joint plot, by default None |
marginal_kws
|
Additional keyword arguments to pass to the marginal plots, by default {"fill": True, "common_norm": False} |
marginal_kind
|
Type of plot to draw in the marginal axes, either "kde" for kernel density estimation or "hist" for histogram, by default "kde"
TYPE:
|
**kwargs
|
Additional styling parameters. Common options include
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
JointGrid
|
The seaborn JointGrid object containing the plot |
Notes
This function will raise a warning if the dataset has fewer than RECOMMENDED_MIN_SAMPLES (30) data points, as density plots are not reliable with small sample sizes.
Examples:
Basic jointplot with default settings:
>>> import soundscapy as sspy
>>> import matplotlib.pyplot as plt
>>> data = sspy.isd.load()
>>> data = sspy.add_iso_coords(data)
>>> g = sspy.jointplot(data)
>>> plt.show()
Jointplot with histogram marginals:
Jointplot with custom styling and grouping:
>>> g = sspy.jointplot(
... data,
... hue="LocationID",
... incl_scatter=True,
... density_type="simple",
... diagonal_lines=True,
... figsize=(6, 6),
... title="Grouped Soundscape Analysis"
... )
>>> plt.show()
>>> plt.close('all')
Source code in src/soundscapy/plotting/plot_functions.py
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 | |
iso_annotation
¶
iso_annotation(
ax: Axes,
data: DataFrame,
location: str,
*,
x_adj: int = 0,
y_adj: int = 0,
x_key: str = DEFAULT_XCOL,
y_key: str = DEFAULT_YCOL,
ha: str = "center",
va: str = "center",
fontsize: str = "small",
arrowprops: dict | None = None,
**text_kwargs,
) -> None
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:
|
Source code in src/soundscapy/plotting/plot_functions.py
1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 | |
scatter_plot
¶
Wrapper for the scatter function to maintain backwards compatibility.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional arguments to pass to the scatter function.
DEFAULT:
|
**kwargs
|
Keyword arguments to pass to the scatter function.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Axes
|
The Axes object containing the plot. |
Source code in src/soundscapy/plotting/plot_functions.py
density_plot
¶
Wrapper for the density function to maintain backwards compatibility.
| PARAMETER | DESCRIPTION |
|---|---|
*args
|
Positional arguments to pass to the density function.
DEFAULT:
|
**kwargs
|
Keyword arguments to pass to the density function.
DEFAULT:
|
| RETURNS | DESCRIPTION |
|---|---|
Axes | ndarray | ISOPlot
|
The Axes object containing the plot. |