Source code for spm1d.plot._effectsize


'''
Effect-size plots.
'''

# Copyright (C) 2026  Todd Pataky

import numpy as np


[docs] def plot_effectsize(es, ax=None, **kwdargs): ''' Plot an effect size object as a bar (0D) or line (1D). :Parameters: - *es* --- **spm1d** effect size object - *ax* --- matplotlib.axes object [default: matplotlib.pyplot.gca()] - *kwdargs* --- keyword arguments passed to **bar** (0D) or **plot** (1D) :Returns: - Axes :Example: The effect size of a paired t test on the plantar arch angle dataset. >>> import spm1d >>> import jikudata as jd >>> from matplotlib import pyplot as plt >>> dataset = jd.PlantarArchAngle() >>> y, A = dataset.y, dataset.x # (20,101) array and (20,) array >>> y0, y1 = y[ A == 0 ], y[ A == 1 ] >>> spmi = spm1d.stats.ttest_paired( y0, y1 ).inference( 0.05 ) >>> es = spmi.effect_size() >>> ax = spm1d.plot.plot_effectsize( es ) # equivalent to es.plot() >>> plt.show() The example datasets require the jiku-data package: ``pip install "spm1d[data]"``. ''' import matplotlib.pyplot as plt ax = plt.gca() if (ax is None) else ax if es.dim == 0: ax.bar([0], [float(es.z)], **kwdargs) ax.set_xticks([]) else: ax.plot(np.asarray(es.z), **kwdargs) ax.set_ylabel(es.name) return ax