-
Convert a plotnine plot object to a
patchworklib.Bricksobject.ggplot: plotnine.ggplot.ggplotfigsize: tuple (float, float)
Figure size. If it is not specified, the generated Bricks object will keep the original figure size of the given ggplot object.
patchworklib.Bricksobject -
Overwrite the
__init__methods inseaborn.axisgrid.xxGridclasses. The function changes the figure object given in the__init__functions of the axisgrid class objects, which is used for drawing plots, to_basefigurein the patchworklib. If you want to load the plots generated based onseaborn.axisgrid.xxGridobjects aspatchworklib.Brick(s)object usingload_seaborngridfunction, you should execute this function in advance.None -
Load a seaborn plot generated based on
seaborn._core.plot.Plotterclass. The method is a prototype version. By using this function, plots generated using object-oriented seaborn interface can be handled as apatchworklib.Brick(s)class object.g:seaborn.axisgrid.xxGridobject
A return value of the seaborn figure-level plotting functions such as relplot, distplot, catplot, jointplot, and pairplot.label: str
Unique identifier for thepatchworklib.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, the converted Bricks object will keep the original figure size of the given seaborn plot.
patchworklib.Bricksobject -
Load seaborn plot generated based on seaborn.axisgrid.xxGrid class.
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 aspatchworklib.Brick(s)class objects.You should execute
overwrite_axisgridfunction before using this function.g: seaborn.axisgrid.xxGrid object
A return value of the seaborn figure-level plotting functions such as relplot, distplot, catplot, jointplot, and pairplot.label: str
Unique identifier for thepatchworklib.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, the converted Bricks object will keep the original figure size of the given seaborn plot.
patchworklib.Bricksobject -
hstack(brick1, brick2, target=None, margin=None, direction='r', adjust_height=True, adjust_width=True, va='top')Align two
patchworklib.Brick(s)objects horizontally. When joining two Brick(s) objects by"|"or"+"operator, this function is called internally.-
brick1 | brick2is identical tohstack(brick1, brick2) -
brick1 + brick2is identical tohstack(brick1, brick2, adjust_height=False)
brick1: patchworklib.Brick or patchworklib.Bricks class object
Apatchworklib.Brick(s)class object to be joined withbrick2object. The location of this object is used as the base position for determining thebrick2placement.brick2: patchworklib.Brick or patchworklib.Bricks class object
Apatchworklib.Brick(s)class object to be placed on the side specified bydirection(by default, on the right side) of thebrick1object.target: str, default:None
Unique label name of the Brick or Brick(s) object that is a part of thebrick1object. If you want to placebrick2object next to the specific Brick(s) object inbrick1object, please provide thelabelvalue of the Brick(s) object.margin: float or str ("none"), default:None
Margin size between the two given Brick(s) objects. IfNone, thepw.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"
Side on whichbrick2is placed with respect tobrick1. "r" means right. "l" means left.adjust_height: bool, default:True
IfTrue, the height ofbrick2object is adjusted so that it will be equal to the height ofbrick1object.adjust_width: bool, default:True
IfTrue, the width ofbrick2will be adjusted according to the aspect ofbrick2after stacking. If False,brick2will keep its original width after stacking. Ifadjust_heightisFalse, the value will also beFalse.va: str ("top"or"bottom"), default:False
Ifadjust_heightisFalse, the value will be effective. If the value is"top",brick2object will be aligned to the left/right top ofbrick1object. If the value is"bottom",brick2object will be aligned to the left/right bottom ofbrick1object.
patchworlib.Bricksobject -
-
vstack(brick1, brick2, target=None, margin=None, direction='t', adjust_height=True, adjust_width=True, ha='l')Align two patchworlib.Brick(s) objects vertically. When joining two Brick(s) objects by "/" or "-" operator, this function is called internally.
-
brick2 / brick1is identical tovstack(brick1, brick2) -
brick2 / brick1is identical tovstack(brick1, brick2, adjust_width=False)
brick1: patchworklib.Brick or patchworklib.Bricks class object
Apatchworlib.Brick(s)class object to be joined withbrick2object. The location of this object is used as the base position for determining thebrick2placement.brick2: patchworklib.Brick or patchworklib.Bricks class object
Apatchworlib.Brick(s)class object to be placed on the side specified bydirection(by default, on the top side) of thebrick1object.target: str, default:None
Unique label name of the Brick or Brick(s) object that is a part of thebrick1object. If you want to placebrick2object next to the specific Brick(s) object inbrick1object, please provide thelabelvalue of the Brick(s) object.margin: flaot, default:pw.param["margin"]
Margin size between the two given Brick(s) objects. IfNone, thepw.param["margin"]value would be used as the margin size. If the value is"none", twopatchworlib.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 ("t" or "b"), default:"t"
Side on whichbrick2is placed with respect tobrick1."t"means top,"b"means bottom.adjust_height: bool, default:True
If True, the height ofbrick2will be adjusted according to the aspect ofbrick2after stacking. If False,brick2will keep its original height after stacking. Ifajust_widthisFasle, the value will also beFalse.adjust_width: bool, default:True
IfTrue, the width ofbrick2object is adjusted so that it will be equal to the width ofbrick1object.ha: str ("left" or "right"), default:False
Ifadjsut_widthisFalse, the value will be effective. If the value is"left",brick2object will be stacked on/below the left top/bottom ofbrick1object. If the value is"right",brick2object will be stacked on/below the right top/bottom ofbrick1object.
patchworlib.Bricksobject -
-
Stack multiple Brick(s) objects horizontally or vetically.
bricks: list of patchworklib.Brick(s) objects
List composed ofpatchworklib.Brick(s)objects. The list can include bothpatchworklib.Brickandpatchworklib.Bricksobjects.margin: float, default:None
Margin size of each Brick(s). If None, thepw.param["margin"]value would be used as the margin size between the Brick(s) objects.operator: str (|,/,+, or-), default:|
Orientation of the arrangement for the givenpatchworklib.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:FalseIf this value isTrue, 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.
patchworlib.Bricksobject -
inset(brick1, brick2, loc='upper right', wratio=0.4, hratio=0.4, vmargin=0.1, hmargin=0.1, alpha=0.0)Position the brick2 object inside the brick1 object.
brick1: patchworklib.Brick or patchworklib.Bricks class object
Brick(s) class object to be joined withbrick2object. The location of this object is used as the base position for determining thebrick2placement.brick2: patchworklib.Brick or patchworklib.Bricks class object
Brick(s) class object to be placed in specified inbrick1object.position: str, ("upper right","lower rigtht","upper left","lower left") Position ofbrick2object inbrick1object.wratio: float, default: 0.1
Ratio of thebrick2width tobrick1object.hratio: float, default: 0.1
Ratio of thebrick2height tobrick1object.vmargin: float, default: 0.1
Margin from the bottom/top.hmargin: float, default: 0.1
Margin from the right/left.alpha: flaot, default: 0.0
Alpha of background ofbrick2object
patchworlib.Bricksobject -
Expand the size of the bricks object.
bricks: patchworklib.Bricks object
Apatchworlib.Brick(s)object to be expand.w: int or float
Expansion ratio of the width of an axes object.h: int or float
Expansion ratio of the width of an axes object.
patchworlib.Bricksobject
Subclass of matplotlib.axes.Axes object.
A patchworklib.Brick object can be joined with another patchworklib.Brick(s) object
using /, |, +, and - operators.
bricks_dict: dict
Dictionaly ofpatchworklib.Brick(s)objects. The label name of the Brick object is served as the dictionaly keys.label: str
Unique identifier for the Bricks class object. The value can be used in layout adjustment using label indexing. The value would be assigned toself.label.
case: matplotlib.Axes.axes
An invisible axes object surrounding Bricks object excluding common label, legend.outline: patchworklib.Bricks
A bricks object based on the invisible axes object surrounding all objects in the original Bricks object includingcaseaxes.label: str
Unique identifier of the Brick class object. If the Brick object is incorporated in the other super Bricks objects, the Brick object can be accessed from the super Bricks object by specifying the label name for the super object asBricks_object[{label}].bricks_dict: dict
Dictionary with labels of the Brick object as a dictionary key and the corresponding Brick object as a dictionary value.
-
This function is the wrapper function of
self.case.text. Set a index label on 'upper left' of the Bricks object. An index labels can be added, such as those on sub-figures published in scientific journals.index: str
index valuex: float
By default, the value will be adjusted as index label is placed on 'upper left' of the Bricks object.y: flaot
By default, the value will be adjusted as index label is placed on 'upper left' of the Bricks object.args: dict
Text properties control the appearance of the label.
matplotlib.text.Textobject -
add_colorbar(self, cmap=None, x=None, y=None, vmin=0, vmax=1, hratio=None, wratio=None, coordinate='relative', **args)Set a colorbar for the Brick object and return a new Bricks object including the colorbar.
cmap: Colormap, default:'viridis'
The colormap to use.x: float, default:None
ifargs['orientation']is'vertical', the value will be adjusted as the colorbar is placed on'lower right'of the Bricks object. ifargs['orientation']is'horizontal', the value will be adjusted as the colorbar is placed on'lower center'of the Bricks object. The zero position forxis the most left axes of the Brick objects in the Bricks object.y: float, default:None
ifargs['orientation']is'vertical', the value will be adjusted as the colorbar is placed on'lower right'of the Bricks object. ifargs['orientation']is'horizontal', the value will be adjusted as the colorbar is placed on 'lower center' of the Bricks object. The zero position foryis the most bottom axes of the Brick objects in the Bricks object.vmin: float, default:0
Minimum value to anchor the colormap.vmax: float, default:1
Maximum value to anchor the colormap.hratio: float
Height ratio of colorbar to height ofself.case.wratio: float
Width ratio of colorbar to width ofself.case.coordinate: str ("relative"or"absolute"), default"relative"
If"absolute", the values of x and y will mean the inches of the distances from the base zero positions. if"relative", the values ofxandywill mean the relative distances based on width and height of Bricks object from the base zero positions.
patchworklib.Bricksobject -
Move legend
new_lock: str or int
Location argument, as in matplotlib.axes.Axes.legend().kws: dict
Other keyword arguments can be used in matplotlib.axes.Axes.legend().
None -
Return the most left, right, bottom, and top positions of the Brick objects.
tuple(left, right, bottom, top) -
Return the left, right, bottom, and top positions of
self.case.patchworklib.Brickobject providescaseattribute.caseis invisiblematplotlib.axes.Axesobject surrounding the Brick object and their artist, text objects.tuple(left, right, bottom, top) -
Return the left, right, bottom, and top positions of
self.outline. Apatchworklib.Brickobject providesoutlineattribute.outlineis Bricks object based on invisiblematplotlib.axes.Axesobject surroundingcaseaxes, and its artist, text objects.tuple(left, right, bottom, top)
A patchworklib.Bricks class object is a collection of patchworklib.Brick object.
It can be joined with aother patchworklib.Brick(s) object by using /, |, -, and + operators.
bricks_dict: dict
Dictionaly of patchworklib.Brick class objects. The label name of each Brick object is served as the dictionaly keys.label: str
Unique identifier for the Bricks class object. The value can be used in layout adjustment using label indexing. The value would be assigned toself.label.
case: matplotlib.Axes.axes
Invisible axes object surrounding Bricks object excluding common label, legend.outline: patchworklib.Bricks
Apatchworklib.Bricksobject based on the invisible axes object surrounding all objects in the original Bricks object includingcaseaxes.label: str
Unique identifier of the Bricks class object. If the Bricks object is incorporated in the other super Bricks objects, by specifying the label name for the super object asBricks_object[{label}], the Bricks object can be accessed from the super Bricks object.bricks_dict: dict
Dictionary with labels of thepatchworklib.Brick(s)objects in the Bricks object as dictionary keys and the correspondingpatchworklib.Brick(s)objects as dictionary values.
-
This function is the wrapper of
self.case.set_xlabel. Set a common xlabel for the Bricks objects. If a Bricks class object is composed of multiple Brick(s) class objects and each has same xaxis labels, you can remove the redundant labels and can add the common x axis label for all Brick(s) objects.xlabel: str
xlabel valuelabelpad: int, default:8
Spacing in points from the virtual axes bounding box of the Bricks object.args: dict
Text properties control the appearance of the label.
matplotlib.text.Textobject -
This function is the wrapper of
self.case.set_ylabel. Set a common ylabel for the Bricks objects. If a Bricks class object is composed of multiple Brick(s) class objects and each has same yaxis labels, you can remove the redundant labels and can add the common y axis label for all Brick(s) objects.ylabel: str
ylabel valuelabelpad: int, default:8
Spacing in points from the virtual axes bounding box of the Bricks object.args: dict
Text properties control the appearance of the label.
matplotlib.text.Textobject -
This function is the wrapper of
self.case.set_title. Set a common title for the Brick(s) objects. If a Bricks class object is composed of multiple Brick(s) class objects and each has common title, you can set common title for all Brick(s) objects.title: str
title valueloc: str ("center","left","right"), default"center"Which title to set.pad: int, default:12
Spacing in points from the virtual axes bounding box of the Bricks object.args: dict
Text properties control the appearance of the label.
matplotlib.text.Textobject -
This function is the wrapper function of
self.case.text. Set a index label on 'upper left' of the Bricks object. An index labels can be added, such as those on sub-figures published in scientific journals.index: str
index valuex: float
By default, the value will be adjusted as index label is placed on 'upper left' of the Bricks object.y: flaot
By default, the value will be adjusted as index label is placed on 'upper left' of the Bricks object.args: dict
Text properties control the appearance of the label.
Returns
matplotlib.text.Textobject -
Set a common spine for the Bric(s) objects in the Bricks object.
The spines ofself.casesurrounding the Bricks object are invisible by default. However, by applying this methods, a specified spine will be visible.which: str ('left', 'right', 'top', 'bottom'), default:"left"
Kind of the spinevisible: bool, default:True
Setting of Show/hide the spineposition: tuple (position type ('outward', 'axes', 'data'), amount (float))
Position of the spine. For details, please see 'https://matplotlib.org/3.5.1/api/spines_api.html'.bounds: tuple (float, float)
Bounds of the spine. For details, please see 'https://matplotlib.org/3.5.1/api/spines_api.html'.
matplotlib.spines.Spineobject -
Align the xlabels of the specified Brick objects.
keys:listofstrorBrickobject The xlabels of the Brick objects specified bykeyswill be aligned.
-
Align the ylabels of the specified Brick objects.
keys:listofstrorBrickobject The ylabels of the Brick objects specified bykeyswill be aligned.
-
add_colorbar(self, cmap=None, x=None, y=None, vmin=0, vmax=1, hratio=None, wratio=None, coordinate='relative', **args)Set a common colorbar for the Bricks objects and return a new Bricks object including the colorbar.
cmap: Colormap, default:'viridis'The colormap to use.x: float, default:None
if args['orientation'] is 'vertical', the value will be adjusted as the colorbar is placed on 'lower right' of the Bricks object. if args['orientation'] is 'horizontal', the value will be adjusted as the colorbar is placed on 'lower center' of the Bricks object. The zero position forxis the most left axes of the Brick objects in the Bricks object.y: float, default:None
if args['orientation'] is 'vertical', the value will be adjusted as the colorbar is placed on 'lower right' of the Bricks object. if args['orientation'] is 'horizontal', the value will be adjusted as the colorbar is placed on 'lower center' of the Bricks object. The zero position foryis the most bottom axes of the Brick objects in the Bricks object.vmin: float, default:0
Minimum value to anchor the colormap.vmax: float, default:1
Maximum value to anchor the colormap.hratio: float
Height ratio of colorbar to height ofself.casewratio: float
Width ratio of colorbar to width ofself.casecoordinate: str ("relative", "absolute"), default:"relative"
if "absolute", the values of x and y will mean the inches of the distances from the base zero positions. if "relative", the values of x and y will mean the relative distances based on width and height of Bricks object from the base zero positions.
patchworklib.Bricksobject -
Move legend.
new_lock: str or int
Location argument, as in matplotlib.axes.Axes.legend().kws: dict
Other keyword arguments can be used in matplotlib.axes.Axes.legend().
None -
Return the the left, right, bottom, and top positions . The inner corners of the Bricks object means the most top left, top right, bottom left, and bottom right corners of the spines of Brick objects in the Bricks object.
tuple(left, right, bottom, top) -
Return the left, right, bottom, and top positions of
self.case. Apatchworklib.Bricksobject providescaseattribute. Acaseis invisiblematplotlib.axes.Axesobject surrounding Brick objects in the Bricks object and their artist, text objects.tuple(left, right, bottom, top) -
Return the left, right, bottom, and top positions of
self.outline. Apatchworklib.Bricksobject hasoutlineattribute. It is a Bricks object based on invisible matplotlib.axes.Axes object surroundingcaseaxes, and its artist, text objects.tuple(left, right, bottom, top)