pingouin.plot_paired

pingouin.plot_paired(data=None, dv=None, within=None, subject=None, order=None, boxplot=True, figsize=(4, 4), dpi=100, ax=None, colors=['green', 'grey', 'indianred'], pointplot_kwargs={'markers': '.', 'scale': 0.6}, boxplot_kwargs={'color': 'lightslategrey', 'width': 0.2})[source]

Paired plot.

Parameters
datapandas DataFrame

Long-format dataFrame.

dvstring

Name of column containing the dependant variable.

withinstring

Name of column containing the within-subject factor. Note that within must have exactly two within-subject levels (= two unique values).

subjectstring

Name of column containing the subject identifier.

orderlist of str

List of values in within that define the order of elements on the x-axis of the plot. If None, uses alphabetical order.

boxplotboolean

If True, add a boxplot to the paired lines using the seaborn.boxplot() function.

figsizetuple

Figsize in inches

dpiint

Resolution of the figure in dots per inches.

axmatplotlib axes

Axis on which to draw the plot.

colorslist of str

Line colors names. Default is green when value increases from A to B, indianred when value decreases from A to B and grey when the value is the same in both measurements.

pointplot_kwargsdict

Dictionnary of optional arguments that are passed to the seaborn.pointplot() function.

boxplot_kwargsdict

Dictionnary of optional arguments that are passed to the seaborn.boxplot() function.

Returns
axMatplotlib Axes instance

Returns the Axes object with the plot for further tweaking.

Notes

Data must be a long-format pandas DataFrame.

Examples

Default paired plot:

>>> from pingouin import read_dataset
>>> df = read_dataset('mixed_anova')
>>> df = df.query("Group == 'Meditation' and Subject > 40")
>>> df = df.query("Time == 'August' or Time == 'June'")
>>> import pingouin as pg
>>> ax = pg.plot_paired(data=df, dv='Scores', within='Time',
...                     subject='Subject', dpi=150)
../_images/pingouin-plot_paired-1.png

Paired plot on an existing axis (no boxplot and uniform color):

>>> from pingouin import read_dataset
>>> df = read_dataset('mixed_anova').query("Time != 'January'")
>>> import pingouin as pg
>>> import matplotlib.pyplot as plt
>>> fig, ax1 = plt.subplots(1, 1, figsize=(5, 4))
>>> pg.plot_paired(data=df[df['Group'] == 'Meditation'],
...                dv='Scores', within='Time', subject='Subject',
...                ax=ax1, boxplot=False,
...                colors=['grey', 'grey', 'grey'])  # doctest: +SKIP
../_images/pingouin-plot_paired-2.png