Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ponnhide committed May 14, 2023
1 parent 23b4783 commit f7ec196
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 23 deletions.
66 changes: 44 additions & 22 deletions API.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Basic functions
## Basic Functions

- ### **`load_ggplot(ggplot=None, figsize=None)`**

Expand All @@ -8,21 +8,20 @@

- `ggplot`: plotnine.ggplot.ggplot
- `figsize`: tuple (float, float)
Figure size. If it is not specified, the generated Bricks object would keep the
original figure size of the given ggplot objecrt.
Figure size. If it is not specified, the generated Bricks object will keep the
original figure size of the given ggplot object.

#### Returns

`patchworklib.Bricks` object


- ### **`overwrite_axisgrid()`**

Overwrite the `__init__` methods in `seaborn.axisgrid.xxGrid` classes.
The function changes the figure object given in the `__init__` functions of the
axisgrid class objects, which is used for drawing plots, to `_basefigure`
in the patchworklib. If you want to load the plots generated based on
`seabron.axisgrid.xxGrid` objects as `patchworklib.Brick(s)` object using
`seaborn.axisgrid.xxGrid` objects as `patchworklib.Brick(s)` object using
`load_seaborngrid` function, you should execute this function in advance.

#### Returns
Expand All @@ -32,22 +31,22 @@
- ### **`load_seabornobj(g, label=None, labels=None, figsize=(3, 3))`**

Load a seaborn plot generated based on `seaborn._core.plot.Plotter` class.
The method is prototype version. By using this function, plots generated
The method is a prototype version. By using this function, plots generated
using [object-oriented seaborn interface](https://seaborn.pydata.org/tutorial/objects_interface.html) can be handled as a `patchworklib.Brick(s)`
class object.

#### Parameters

- `g`: `seaborn.axisgrid.xxGrid` object
A return value of the seaborn figure-level plotting functions such as relplot,
distplot, catplot, jointplot and pairplot.
distplot, catplot, jointplot, and pairplot.
- `label`: str
Unique identifier for the `patchworklib.Brick(s)` class object to be returned.
If you want to adjust a layout composed of multiple bricks object using the label
indexing method, providing the unique label name for returned object should be
encouraged.
- `figsize`: tuple (float, float)
Figure size. If it is not specified, convert Bricks object would keep the original
Figure size. If it is not specified, the converted Bricks object will keep the original
figure size of the given seaborn plot.

#### Returns
Expand All @@ -57,9 +56,9 @@
- ### **`load_seaborngrid(g, label=None, labels=None, figsize=None)`**

Load seaborn plot generated based on seaborn.axisgrid.xxGrid class.
In generally, seaborn plots generated by figure-level fucntion cannot be
handles as subplot(s) with other matplotlib plots, However, by processing
these seaborn plots via the function, you can handle them as
In general, seaborn plots generated by figure-level function cannot be
handled as subplot(s) with other matplotlib plots. However, by processing
these seaborn plots via this function, you can handle them as
`patchworklib.Brick(s)` class objects.

#### Notes
Expand All @@ -70,14 +69,14 @@

- `g`: seaborn.axisgrid.xxGrid object
A return value of the seaborn figure-level plotting functions such as relplot,
distplot, catplot, jointplot and pairplot.
distplot, catplot, jointplot, and pairplot.
- `label`: str
Unique identifier for the `patchworklib.Brick(s)` class object to be returned.
If you want to adjust a layout composed of multiple bricks object using the label
indexing method, providing the unique label name for returned object should be
encouraged.
- `figsize`: tuple (float, float)
Figure size. If it is not specified, convert Bricks object would keep the original
Figure size. If it is not specified, the converted Bricks object will keep the original
figure size of the given seaborn plot.

#### Returns
Expand All @@ -86,7 +85,7 @@

- ### **`hstack(brick1, brick2, target=None, margin=None, direction='r', adjust_height=True, adjust_width=True, va='top')`**

Align two `patchworlib.Brick(s)` objects horizontally.
Align two `patchworklib.Brick(s)` objects horizontally.
When joining two Brick(s) objects by `"|"` or `"+"` operator, this function is called internally.

- `brick1 | brick2` is identical to `hstack(brick1, brick2)`
Expand All @@ -96,19 +95,19 @@
#### Parameters

- `brick1`: patchworklib.Brick or patchworklib.Bricks class object
A `patchworlib.Brick(s)` class object to be joined with `brick2` object.
A `patchworklib.Brick(s)` class object to be joined with `brick2` object.
The location of this object is used as the base position for determining
the `brick2` placement.
- `brick2`: patchworklib.Brick or patchworklib.Bricks class object
A `patchworlib.Brick(s)` class object to be placed on the side specified by `direction`
A `patchworklib.Brick(s)` class object to be placed on the side specified by `direction`
(by default, on the right side) of the `brick1` object.
- `target`: str, default: `None`
Unique label name of the Brick or Brick(s) object that is a part of the `brick1`
object. If you want to place `brick2` object next to the specific Brick(s) object
in `brick1` object, please provide the `label` value of the Brick(s) object.
- `margin`: float or str (`"none"`), default: `None`
Margin size between the two given Brick(s) objects.
If `None`, the `pw.param["margin"]` value would be used as the margin size.
If `None`, the `pw.param["margin"]` value will be used as the margin size.
If the value is `"none"`, two Brick(s) objects will be joined with no margin
(meaning that the axes spines will be joined so that they are fully glued together).
- `direction`: str (`"r"` or `"l"`), default: `"r"`
Expand All @@ -120,15 +119,17 @@
- `adjust_width`: bool, default: `True`
If `True`, the width of `brick2` will be adjusted according to the aspect of `brick2`
after stacking. If False, `brick2` will keep its original width after stacking.
If `ajust_height` is `Fasle`, the value will also be `False`.
If `adjust_height` is `False`, the value will also be `False`.
- `va`: str (`"top"` or `"bottom"`), default: `False`
If `adjsut_height` is `False`, the value will be effective.
If `adjust_height` is `False`, the value will be effective.
If the value is `"top"`, `brick2` object will be aligned to the left/right top of `brick1` object.
If the value is `"bottom"`, `brick2` object will be aligned to the left/right bottom of `brick1` object.

#### Returns

`patchworlib.Bricks` object


`patchworklib.Bricks` object

- ### **`vstack(brick1, brick2, target=None, margin=None, direction='t', adjust_height=True, adjust_width=True, ha='l')`**

Expand Down Expand Up @@ -176,7 +177,7 @@

`patchworlib.Bricks` object

- ### **`stack(bricks, margin=None, operator='|')`**
- ### **`stack(bricks, margin=None, operator='|', equal_spacing=False)`**

Stack multiple Brick(s) objects horizontally or vetically.

Expand All @@ -192,7 +193,11 @@
Orientation of the arrangement for the given `patchworklib.Brick(s)` object.
If this value is `|` or `/`, the width/height of the object to be stacked will be
adjusted so that it will be aligned with previous one.

- `equal_spacing`: bool, default: `False`
If this value is `True`, axes bounding-boxes should be placed with equal spacing
between them. Otherwise, depending on the text values of x/y tick labels and x/y
labels, they may not always be equally spaced.

#### Returns

`patchworlib.Bricks` object
Expand Down Expand Up @@ -521,6 +526,23 @@ It can be joined with aother `patchworklib.Brick(s)` object by using `/`, `|`, `
`matplotlib.spines.Spine` object


- ### **`align_xlabels(self, keys=None)`**

Align the xlabels of the specified Brick objects.

#### Parameters

- `keys`: `list` of `str` or `Brick` object
The xlabels of the Brick objects specified by `keys` will be aligned.

- ### **`align_ylabels(self, keys=None)`**

Align the ylabels of the specified Brick objects.

#### Parameters

- `keys`: `list` of `str` or `Brick` object
The ylabels of the Brick objects specified by `keys` will be aligned.

- ### **`add_colorbar(self, cmap=None, x=None, y=None, vmin=0, vmax=1, hratio=None, wratio=None, coordinate='relative', **args)`**

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ If you want to use developmental version, it can be installed using the followin

#### 05152023: version 0.6.0 is released.
- Bricks object gained the new methods `align_xlabels` and `align_ylabels`, which help users align x/y labels of the given Brick object.
- The new argument equal_spacing was added to the stack function. If this value is set to True, axes bounding-boxes should be placed with equal spacing between them. Otherwise, depending on the text values of x/y tick labels and x/y labels, they may not always be equally spaced.
- The new argument `equal_spacing` was added to the stack function. If this value is `True`, axes bounding-boxes should be placed with equal spacing between them. Otherwise, depending on the text values of x/y tick labels and x/y labels, they may not always be equally spaced.
- Closed and maybe solved the issue ["Align labels of Bricks when subplot axes are aligned. #40"](https://github.com/ponnhide/patchworklib/issues/40)
- Closed and maybe solved the issue ["Doesn't work with Plotnine Seaborn Theme. #37"](https://github.com/ponnhide/patchworklib/issues/37)
- Closed and maybe solved the issue ["The position of the title cannot be set in plotnine. #36"](https://github.com/ponnhide/patchworklib/issues/36)
Expand Down

0 comments on commit f7ec196

Please sign in to comment.