From f7ec196b0d32f95a4c32124f9ceb595cc74c1633 Mon Sep 17 00:00:00 2001 From: ponnhide Date: Mon, 15 May 2023 01:35:53 +0900 Subject: [PATCH] Updated --- API.md | 66 ++++++++++++++++++++++++++++++++++++------------------- README.md | 2 +- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/API.md b/API.md index 918c53c..df8c34a 100644 --- a/API.md +++ b/API.md @@ -1,4 +1,4 @@ -## Basic functions +## Basic Functions - ### **`load_ggplot(ggplot=None, figsize=None)`** @@ -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 @@ -32,7 +31,7 @@ - ### **`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. @@ -40,14 +39,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 @@ -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 @@ -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 @@ -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)` @@ -96,11 +95,11 @@ #### 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` @@ -108,7 +107,7 @@ 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"` @@ -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')`** @@ -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. @@ -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 @@ -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)`** diff --git a/README.md b/README.md index dfa12bf..46b7175 100644 --- a/README.md +++ b/README.md @@ -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)