From ad881c36ef543c78e5eeaf11f4c91ec8c2e48bd1 Mon Sep 17 00:00:00 2001 From: Kim Date: Thu, 16 Feb 2023 11:15:05 +0100 Subject: [PATCH 1/3] Add test including both seaborn and plotnine --- tests/test_patchworklib.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/test_patchworklib.py b/tests/test_patchworklib.py index b9461f1..78b6c25 100644 --- a/tests/test_patchworklib.py +++ b/tests/test_patchworklib.py @@ -1,5 +1,6 @@ from pathlib import Path +import plotnine as p9 import seaborn as sns import patchworklib as pw @@ -25,3 +26,26 @@ def test_example_plot(tmp_path: Path): ax12 = ax1 | ax2 ax12.savefig(result_file) assert result_file.exists() + + +def test_sns_and_p9(tmp_path: Path): + fmri = sns.load_dataset("fmri") + + g_sns = pw.Brick(figsize=(4, 4)) + sns.boxplot(data=fmri, x="sex", y="survived", hue="class", ax=g_sns) + g_sns.set_title("seaborn") + + g_p9 = pw.load_ggplot( + ( + p9.ggplot(fmri, p9.aes(x="sex", y="survived", fill="hue")) + + p9.geom_boxplot() + + p9.ggtitle("plotnine") + ), + figsize=(4, 4), + ) + + g = g_sns | g_p9 + + result_file = tmp_path / "g.png" + g.savefig(result_file) + assert result_file.exists() From 2edb0e21acc04ae0d7e8af302bc1ecba1c20e0d3 Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 20 Feb 2023 15:39:07 +0100 Subject: [PATCH 2/3] Fix dataset --- tests/test_patchworklib.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_patchworklib.py b/tests/test_patchworklib.py index 78b6c25..245780c 100644 --- a/tests/test_patchworklib.py +++ b/tests/test_patchworklib.py @@ -29,15 +29,15 @@ def test_example_plot(tmp_path: Path): def test_sns_and_p9(tmp_path: Path): - fmri = sns.load_dataset("fmri") + titanic = sns.load_dataset("titanic") g_sns = pw.Brick(figsize=(4, 4)) - sns.boxplot(data=fmri, x="sex", y="survived", hue="class", ax=g_sns) + sns.boxplot(data=titanic, x="sex", y="survived", hue="class", ax=g_sns) g_sns.set_title("seaborn") g_p9 = pw.load_ggplot( ( - p9.ggplot(fmri, p9.aes(x="sex", y="survived", fill="hue")) + p9.ggplot(titanic, p9.aes(x="sex", y="survived", fill="hue")) + p9.geom_boxplot() + p9.ggtitle("plotnine") ), From b98dace82e42c025371e9cb1aa9e7f0293724831 Mon Sep 17 00:00:00 2001 From: Kim Date: Mon, 20 Feb 2023 15:47:11 +0100 Subject: [PATCH 3/3] Another fix --- tests/test_patchworklib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_patchworklib.py b/tests/test_patchworklib.py index 245780c..ffaa931 100644 --- a/tests/test_patchworklib.py +++ b/tests/test_patchworklib.py @@ -37,7 +37,7 @@ def test_sns_and_p9(tmp_path: Path): g_p9 = pw.load_ggplot( ( - p9.ggplot(titanic, p9.aes(x="sex", y="survived", fill="hue")) + p9.ggplot(titanic, p9.aes(x="sex", y="survived", fill="class")) + p9.geom_boxplot() + p9.ggtitle("plotnine") ),