lets_plot.bistro.joint.joint_plot#

lets_plot.bistro.joint.joint_plot(data, x, y, *, geom=None, bins=None, binwidth=None, color=None, size=None, alpha=None, color_by=None, show_legend=None, reg_line=None, se=None, marginal=None)#

Produce a joint plot that contains bivariate and univariate graphs at the same time.

Parameters:
datadict or Pandas or Polars DataFrame

The data to be displayed.

x, ystr

Names of a variables.

geom{‘point’, ‘tile’, ‘density2d’, ‘density2df’}, default=’point’

The geometric object to use to display the data.

binsint or list of int

Number of bins in both directions, vertical and horizontal. Overridden by binwidth. If only one value given - interpret it as list of two equal values. Applicable simultaneously for ‘tile’ geom and ‘histogram’ marginal.

binwidthfloat or list of float

The width of the bins in both directions, vertical and horizontal. Overrides bins. The default is to use bin widths that cover the entire range of the data. If only one value given - interpret it as list of two equal values. Applicable simultaneously for ‘tile’ geom and ‘histogram’ marginal.

colorstr

Color of the geometry.

sizefloat

Size of the geometry.

alphafloat

Transparency level of the geometry. Accept values between 0 and 1.

color_bystr

Name of grouping variable.

show_legendbool, default=True

False - do not show legend for the main layer.

reg_linebool

True - show the line of linear regression.

sebool, default=True

Display confidence interval around regression line.

marginalstr, default=’dens:r’

Description of marginal layers packed to string value. Different marginals are separated by the ‘,’ char. Parameters of a marginal are separated by the ‘:’ char. First parameter of a marginal is a geometry name. Possible values: ‘dens’/’density’, ‘hist’/’histogram’, ‘box’/’boxplot’. Second parameter is a string specifying which sides of the plot the marginal layer will appear on. Possible values: ‘t’ (top), ‘b’ (bottom), ‘l’ (left), ‘r’ (right). Third parameter (optional) is size of marginal. To suppress marginals use marginal=’none’. Examples: “hist:tr:0.3”, “dens:tr,hist:bl”, “box:tr:.05, hist:bl, dens:bl”.

Returns:
PlotSpec

Plot object specification.

Examples

 1import numpy as np
 2from lets_plot import *
 3from lets_plot.bistro.joint import *
 4LetsPlot.setup_html()
 5n = 100
 6np.random.seed(42)
 7data = {
 8    'x': np.random.normal(size=n),
 9    'y': np.random.normal(size=n)
10}
11joint_plot(data, 'x', 'y')

 1import numpy as np
 2from lets_plot import *
 3from lets_plot.bistro.joint import *
 4LetsPlot.setup_html()
 5n = 500
 6np.random.seed(42)
 7data = {
 8    'x': np.random.normal(size=n),
 9    'y': np.random.normal(size=n)
10}
11joint_plot(data, 'x', 'y', geom='tile', \
12           binwidth=[.5, .5], color="black", \
13           marginal="hist:tr,box:bl") + \
14    theme_minimal()

 1import numpy as np
 2from lets_plot import *
 3from lets_plot.bistro.joint import *
 4LetsPlot.setup_html()
 5n = 500
 6np.random.seed(42)
 7data = {
 8    'x': np.concatenate((np.random.normal(loc=-1, size=n), np.random.normal(loc=2, size=n))),
 9    'y': np.concatenate((np.random.normal(loc=-.5, size=n), np.random.normal(loc=1.5, size=n))),
10    'g': ["A"] * n + ["B"] * n
11}
12joint_plot(data, 'x', 'y', geom='density2df', color_by='g', alpha=.75)