Skip to content

Dealing with results

SSMParams

Bases: object

A class to store the results of a single SSM analysis.

ATTRIBUTE DESCRIPTION
scores

A numeric vector (or single row dataframe) containing one score for each of a set of circumplex scales.

TYPE: array

angles

A numeric vector containing the angular displacement of each circumplex scale included in scores.

TYPE: tuple

scales

A list of the names of the circumplex scales included in scores.

TYPE: list

group

A list of the names of the groups included in scores.

TYPE: list

measure

A list of the names of the measures included in scores.

TYPE: list

elevation

The elevation of the SSM curve.

TYPE: float

xval

The x-value of the SSM curve.

TYPE: float

yval

The y-value of the SSM curve.

TYPE: float

amplitude

The amplitude of the SSM curve.

TYPE: float

displacement

The displacement of the SSM curve.

TYPE: float

r2

The R2 fit of the SSM curve.

TYPE: float

Source code in circumplex/circumplex.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def __init__(
    self,
    scores: np.array,
    scales: list,
    angles: tuple = OCTANTS,
    group: list = None,
    measure: list | str = None,
    bounds: tuple = BOUNDS,
):
    self.scores = scores
    self.angles = angles
    self.scales = scales
    self.group = group
    self.measure = measure
    (
        self.elevation,
        self.xval,
        self.yval,
        self.amplitude,
        self.displacement,
        self.r2,
    ) = ssm_parameters(self.scores, self.angles, bounds=bounds)

label property

label

Return a label for the SSMParams object.

table property

table

Return a table of the results.

plot

plot()

Plot the results in the circumplex

RETURNS DESCRIPTION
Axes

plt.Axes: A tuple containing the figure and axis objects.

Source code in circumplex/circumplex.py
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
def plot(self) -> plt.Axes:
    """
    Plot the results in the circumplex

    Returns:
        plt.Axes: A tuple containing the figure and axis objects.
    """
    fig, ax = plt.subplots(subplot_kw={"projection": "polar"})
    ax.plot(
        np.deg2rad(self.displacement),
        self.amplitude,
        color="black",
        marker="o",
        markersize=10,
    )

profile_plot

profile_plot(ax=None, **kwargs)

Plot the SSM profile.

RETURNS DESCRIPTION
Axes

plt.Axes: A tuple containing the figure and axis objects.

Source code in circumplex/circumplex.py
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
def profile_plot(self, ax=None, **kwargs) -> plt.Axes:
    """
    Plot the SSM profile.

    Returns:
        plt.Axes: A tuple containing the figure and axis objects.
    """
    return profile_plot(
        self.amplitude,
        self.displacement,
        self.elevation,
        self.r2,
        self.angles,
        self.scores,
        self.label,
        ax=ax,
        **kwargs,
    )

SSMResults

Bases: object

A class to store the results of a SSM analysis.

ATTRIBUTE DESCRIPTION
results

A list containing the SSMParams results of the SSM analysis.

TYPE: list[SSMParams]

measures

A list of the names of the measures included in scores.

TYPE: list

grouping

A list of the names of the groups included in scores.

TYPE: list

Source code in circumplex/circumplex.py
161
162
163
164
165
166
167
168
169
170
171
def __init__(
    self, results: list[SSMParams] | SSMParams, measures=None, grouping=None
):
    if isinstance(results, SSMParams):
        measures = [results.measure]
        grouping = [results.group]
        results = [results]

    self.results = results
    self.measures = measures
    self.grouping = grouping

groups property

groups

Return a list of the groups included in the analysis.

labels property

labels

Return a list of the labels included in the analysis.

table property

table

Return a table of the results.

RETURNS DESCRIPTION
DataFrame

pd.DataFrame: A dataframe containing the results of the SSM analysis.

plot

plot(colors=None, legend=True, *args, **kwargs)

Plot the results in the circumplex

RETURNS DESCRIPTION
Axes

plt.Axes: A tuple containing the figure and axis objects.

Source code in circumplex/circumplex.py
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
def plot(self, colors=None, legend=True, *args, **kwargs) -> plt.Axes:
    """
    Plot the results in the circumplex

    Returns:
        plt.Axes: A tuple containing the figure and axis objects.
    """
    fig, ax = plt.subplots(subplot_kw={"projection": "polar"})
    if colors is None:
        colors = colormaps.get_cmap("tab20").colors
    colors = iter(colors)
    for res in self.results:
        ax.plot(
            np.deg2rad(res.displacement),
            res.amplitude,
            color=next(colors),
            marker="o",
            markersize=10,
            label=res.label,
        )
    fig.legend(loc="upper right", bbox_to_anchor=(1.2, 1))
    return fig, ax

profile_plots

profile_plots(axes=None)

Plot the SSM profiles.

RETURNS DESCRIPTION
Axes

plt.Axes: A tuple containing the figure and axis objects.

Source code in circumplex/circumplex.py
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
def profile_plots(self, axes=None) -> plt.Axes:
    """
    Plot the SSM profiles.

    Returns:
        plt.Axes: A tuple containing the figure and axis objects.
    """
    if axes is None:
        fig, axes = plt.subplots(
            nrows=len(self.results),
            figsize=(8, 4 * len(self.results)),
        )
    for i, res in enumerate(self.results):
        # BUG: Raises error if we only need a single plot
        fig, ax = res.profile_plot(ax=axes.flatten()[i])
    plt.tight_layout()
    # plt.show()
    return fig, axes

query_label

query_label(label)

Query the results for a specific SSMParams by label.

Source code in circumplex/circumplex.py
199
200
201
202
203
204
205
206
def query_label(self, label: str) -> SSMParams:
    """Query the results for a specific SSMParams by label."""
    for res in self.results:
        if res.label == label:
            return res
    raise ValueError(
        f"No results found for {label}"
    )  # Raised if the label is never found