-
Convert a plotnine plot object to a
patchworklib.Bricks
object.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.Bricks
object -
Overwrite the
__init__
methods inseaborn.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 onseaborn.axisgrid.xxGrid
objects aspatchworklib.Brick(s)
object usingload_seaborngrid
function, you should execute this function in advance.None
-
Load a seaborn plot generated based on
seaborn._core.plot.Plotter
class. 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.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.Bricks
object -
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_axisgrid
function 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.Bricks
object -
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 | brick2
is identical tohstack(brick1, brick2)
-
brick1 + brick2
is identical tohstack(brick1, brick2, adjust_height=False)
brick1
: patchworklib.Brick or patchworklib.Bricks class object
Apatchworklib.Brick(s)
class object to be joined withbrick2
object. The location of this object is used as the base position for determining thebrick2
placement.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 thebrick1
object.target
: str, default:None
Unique label name of the Brick or Brick(s) object that is a part of thebrick1
object. If you want to placebrick2
object next to the specific Brick(s) object inbrick1
object, please provide thelabel
value 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 whichbrick2
is placed with respect tobrick1
. "r" means right. "l" means left.adjust_height
: bool, default:True
IfTrue
, the height ofbrick2
object is adjusted so that it will be equal to the height ofbrick1
object.adjust_width
: bool, default:True
IfTrue
, the width ofbrick2
will be adjusted according to the aspect ofbrick2
after stacking. If False,brick2
will keep its original width after stacking. Ifadjust_height
isFalse
, the value will also beFalse
.va
: str ("top"
or"bottom"
), default:False
Ifadjust_height
isFalse
, the value will be effective. If the value is"top"
,brick2
object will be aligned to the left/right top ofbrick1
object. If the value is"bottom"
,brick2
object will be aligned to the left/right bottom ofbrick1
object.
patchworlib.Bricks
object -
-
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 / brick1
is identical tovstack(brick1, brick2)
-
brick2 / brick1
is identical tovstack(brick1, brick2, adjust_width=False)
brick1
: patchworklib.Brick or patchworklib.Bricks class object
Apatchworlib.Brick(s)
class object to be joined withbrick2
object. The location of this object is used as the base position for determining thebrick2
placement.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 thebrick1
object.target
: str, default:None
Unique label name of the Brick or Brick(s) object that is a part of thebrick1
object. If you want to placebrick2
object next to the specific Brick(s) object inbrick1
object, please provide thelabel
value 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 whichbrick2
is placed with respect tobrick1
."t"
means top,"b"
means bottom.adjust_height
: bool, default:True
If True, the height ofbrick2
will be adjusted according to the aspect ofbrick2
after stacking. If False,brick2
will keep its original height after stacking. Ifajust_width
isFasle
, the value will also beFalse
.adjust_width
: bool, default:True
IfTrue
, the width ofbrick2
object is adjusted so that it will be equal to the width ofbrick1
object.ha
: str ("left" or "right"), default:False
Ifadjsut_width
isFalse
, the value will be effective. If the value is"left"
,brick2
object will be stacked on/below the left top/bottom ofbrick1
object. If the value is"right"
,brick2
object will be stacked on/below the right top/bottom ofbrick1
object.
patchworlib.Bricks
object -
-
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.Brick
andpatchworklib.Bricks
objects.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:False
If 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.Bricks
object -
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 withbrick2
object. The location of this object is used as the base position for determining thebrick2
placement.brick2
: patchworklib.Brick or patchworklib.Bricks class object
Brick(s) class object to be placed in specified inbrick1
object.position
: str, ("upper right"
,"lower rigtht"
,"upper left"
,"lower left"
) Position ofbrick2
object inbrick1
object.wratio
: float, default: 0.1
Ratio of thebrick2
width tobrick1
object.hratio
: float, default: 0.1
Ratio of thebrick2
height tobrick1
object.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 ofbrick2
object
patchworlib.Bricks
object -
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.Bricks
object
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 includingcase
axes.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.Text
object -
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 forx
is 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 fory
is 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 ofx
andy
will mean the relative distances based on width and height of Bricks object from the base zero positions.
patchworklib.Bricks
object -
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.Brick
object providescase
attribute.case
is invisiblematplotlib.axes.Axes
object 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.Brick
object providesoutline
attribute.outline
is Bricks object based on invisiblematplotlib.axes.Axes
object surroundingcase
axes, 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.Bricks
object based on the invisible axes object surrounding all objects in the original Bricks object includingcase
axes.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.Text
object -
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.Text
object -
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.Text
object -
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.Text
object -
Set a common spine for the Bric(s) objects in the Bricks object.
The spines ofself.case
surrounding 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.Spine
object -
Align the xlabels of the specified Brick objects.
keys
:list
ofstr
orBrick
object The xlabels of the Brick objects specified bykeys
will be aligned.
-
Align the ylabels of the specified Brick objects.
keys
:list
ofstr
orBrick
object The ylabels of the Brick objects specified bykeys
will 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 forx
is 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 fory
is 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", "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.Bricks
object -
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.Bricks
object providescase
attribute. Acase
is invisiblematplotlib.axes.Axes
object 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.Bricks
object hasoutline
attribute. It is a Bricks object based on invisible matplotlib.axes.Axes object surroundingcase
axes, and its artist, text objects.tuple
(left, right, bottom, top)