Skip to content

Commit

Permalink
Merge pull request #34 from kpj/feature-test
Browse files Browse the repository at this point in the history
Add test including both seaborn and plotnine
  • Loading branch information
ponnhide committed Feb 20, 2023
2 parents c81c769 + b98dace commit 7c4cb5a
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/test_patchworklib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pathlib import Path

import plotnine as p9
import seaborn as sns

import patchworklib as pw
Expand All @@ -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):
titanic = sns.load_dataset("titanic")

g_sns = pw.Brick(figsize=(4, 4))
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(titanic, p9.aes(x="sex", y="survived", fill="class"))
+ 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()

0 comments on commit 7c4cb5a

Please sign in to comment.