Skip to content

Commit 19a2883

Browse files
committed
update
2 parents 89fb7f9 + 20130c6 commit 19a2883

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

API.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,22 +203,22 @@
203203

204204
#### Parameters
205205

206-
- `brick1`: patchworklib.Brick or patchworklib.Bricks class object
206+
- `brick1`: patchworklib.Brick or patchworklib.Bricks class object
207207
Brick(s) class object to be joined with `brick2` object. The location of this
208208
object is used as the base position for determining the `brick2` placement.
209-
- `brick2`: patchworklib.Brick or patchworklib.Bricks class object
209+
- `brick2`: patchworklib.Brick or patchworklib.Bricks class object
210210
Brick(s) class object to be placed in specified in `brick1` object.
211211
- `position`: str, (`"upper right"`, `"lower rigtht"`, `"upper left"`, `"lower left"`)
212212
Position of `brick2` object in `brick1` object.
213-
- `wratio`: float, default: 0.1
213+
- `wratio`: float, default: 0.1
214214
Ratio of the `brick2` width to `brick1` object.
215-
- `hratio`: float, default: 0.1
215+
- `hratio`: float, default: 0.1
216216
Ratio of the `brick2` height to `brick1` object.
217-
- `vmargin`: float, default: 0.1
217+
- `vmargin`: float, default: 0.1
218218
Margin from the bottom/top.
219-
- `hmargin`: float, default: 0.1
219+
- `hmargin`: float, default: 0.1
220220
Margin from the right/left.
221-
- `alpha`: flaot, default: 0.0
221+
- `alpha`: flaot, default: 0.0
222222
Alpha of background of `brick2` object
223223

224224
#### Returns

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ If you want to use developmental version, it can be installed using the followin
1717
- New operators, "+" and "-", were added.
1818
- plotnine > v0.10.x is now supported.
1919
- Plots generated by object-oriented seaborn interface can now be handled by patchworklib.
20-
- Descriptions of each function and class provided in patchworklib is added to this repository. If you want to know the detailed usage of patchworklib, please see [API.md](https://github.com/ponnhide/patchworklib/blob/v0.5.0/API.md).
20+
- Descriptions of each function and class provided in patchworklib was added to this repository. If you want to know how to use patchworklib in detail, please see [API.md](https://github.com/ponnhide/patchworklib/blob/main/API.md).
2121
- Updated [patchworklib-examples](https://github.com/ponnhide/patchworklib-examples)
2222

2323
<details>
@@ -294,6 +294,8 @@ g1234.savefig()
294294
</details>
295295

296296
## Usage
297+
> _If you want to know how to use patchworklib in detail, please see [API.md](https://github.com/ponnhide/patchworklib/blob/main/API.md)._
298+
>
297299
Using `patchworklib`, you can quickly and freely arrange matplotlib plots with only `|` and `/` oparators as follows.
298300

299301
```python

patchworklib/patchworklib.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,9 @@ def load_seabornobj(g, label=None, labels=None, figsize=(3,3)):
665665
if len(g._subplots._subplot_list) > 1:
666666
outers = bricks.get_inner_corner()
667667
expand(bricks, figsize[0]/abs(outers[0]-outers[1]), figsize[1]/abs(outers[3]-outers[2]))
668-
669-
x0, x1, y0, y1 = bricks.get_outer_corner()
670-
bricks._originalsize = (abs(x1-x0), abs(y0-y1))
671-
if type(bricks) == Bricks:
668+
x0, x1, y0, y1 = bricks.get_outer_corner()
669+
bricks._originalsize = (abs(x1-x0), abs(y0-y1))
672670
bricks.set_originalpositions()
673-
674671
return bricks
675672

676673
def load_seaborngrid(g, label=None, labels=None, figsize=None):

tests/test_patchworklib.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from pathlib import Path
22

3+
import plotnine as p9
34
import seaborn as sns
45

56
import patchworklib as pw
@@ -25,3 +26,26 @@ def test_example_plot(tmp_path: Path):
2526
ax12 = ax1 | ax2
2627
ax12.savefig(result_file)
2728
assert result_file.exists()
29+
30+
31+
def test_sns_and_p9(tmp_path: Path):
32+
titanic = sns.load_dataset("titanic")
33+
34+
g_sns = pw.Brick(figsize=(4, 4))
35+
sns.boxplot(data=titanic, x="sex", y="survived", hue="class", ax=g_sns)
36+
g_sns.set_title("seaborn")
37+
38+
g_p9 = pw.load_ggplot(
39+
(
40+
p9.ggplot(titanic, p9.aes(x="sex", y="survived", fill="class"))
41+
+ p9.geom_boxplot()
42+
+ p9.ggtitle("plotnine")
43+
),
44+
figsize=(4, 4),
45+
)
46+
47+
g = g_sns | g_p9
48+
49+
result_file = tmp_path / "g.png"
50+
g.savefig(result_file)
51+
assert result_file.exists()

0 commit comments

Comments
 (0)