Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aesthetic flexibility to plot_rm_corr #312

Merged
merged 3 commits into from
Nov 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ We have added the :py:func:`pingouin.ptests` function to calculate a T-test (T-
>>> df = pg.read_dataset('pairwise_corr').iloc[:30, 1:]
>>> df.ptests()

**Improvements**

Added customization options to :py:func:`pingouin.plot_rm_corr`, which now takes optional keyword arguments to pass through to py:func:`seaborn.regplot` and `seaborn.scatterplot`. `PR 312 <https://github.com/raphaelvallat/pingouin/pull/312>`_.

*************

v0.5.2 (June 2022)
Expand Down
19 changes: 15 additions & 4 deletions pingouin/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,14 @@ def adjacent_values(vals, q1, q3):


def plot_rm_corr(
data=None, x=None, y=None, subject=None, legend=False, kwargs_facetgrid=dict(height=4, aspect=1)
data=None,
x=None,
y=None,
subject=None,
legend=False,
kwargs_facetgrid=dict(height=4, aspect=1),
kwargs_line=dict(ls="solid"),
kwargs_scatter=dict(marker="o"),
):
"""Plot a repeated measures correlation.

Expand All @@ -914,7 +921,11 @@ def plot_rm_corr(
If True, add legend to plot. Legend will show all the unique values in
``subject``.
kwargs_facetgrid : dict
Optional keyword argument passed to :py:class:`seaborn.FacetGrid`
Optional keyword arguments passed to :py:class:`seaborn.FacetGrid`
kwargs_line : dict
Optional keyword arguments passed to :py:class:`matplotlib.pyplot.plot`
kwargs_scatter : dict
Optional keyword arguments passed to :py:class:`matplotlib.pyplot.scatter`

Returns
-------
Expand Down Expand Up @@ -1006,8 +1017,8 @@ def plot_rm_corr(

# Start plot
g = sns.FacetGrid(data, hue=subject, **kwargs_facetgrid)
g = g.map(sns.regplot, x, "pred", scatter=False, ci=None, truncate=True)
g = g.map(sns.scatterplot, x, y)
g = g.map(sns.regplot, x, "pred", scatter=False, ci=None, truncate=True, line_kws=kwargs_line)
g = g.map(sns.scatterplot, x, y, **kwargs_scatter)

if legend:
g.add_legend()
Expand Down
1 change: 0 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pytest>=4.6
codecov
pytest-cov
pytest-travis-fold
openpyxl
mpmath