lets_plot.bistro.qq.qq_plot

lets_plot.bistro.qq.qq_plot(data=None, sample=None, *, x=None, y=None, distribution=None, dparams=None, quantiles=None, group=None, show_legend=None, color=None, fill=None, alpha=None, size=None, shape=None, line_color=None, line_size=None, linetype=None) lets_plot.plot.core.PlotSpec

Produces a Q-Q plot (quantile-quantile plot).

Supply the sample parameter to compare distribution of observations with a theoretical distribution (‘normal’ or as otherwise specified by the distribution parameter).

Alternatively, supply x and y parameters to compare the distribution of x with the distribution of y.

Parameters
datadict or DataFrame

The data to be displayed.

samplestr

Name of variable. Specifies a vector of observations used for computing of “sample quantiles”. Use this parameter to produce a “sample vs. theoretical” Q-Q plot.

x, ystr

Names of variables specifying two vectors of observations used for computing of x and y “sample quantiles”. Use these two parameters to produce a “sample X vs. sample Y” Q-Q plot.

distribution{‘norm’, ‘uniform’, ‘t’, ‘gamma’, ‘exp’, ‘chi2’}, default=’norm’

Distribution function to use. Could be specified if sample is.

dparamslist

Additional parameters (of float type) passed on to distribution function. Could be specified if sample is. If distribution is ‘norm’ then dparams is a pair [mean, std] (=[0.0, 1.0] by default). If distribution is ‘uniform’ then dparams is a pair [a, b] (=[0.0, 1.0] by default). If distribution is ‘t’ then dparams is an integer number [d] (=[1] by default). If distribution is ‘gamma’ then dparams is a pair [alpha, beta] (=[1.0, 1.0] by default). If distribution is ‘exp’ then dparams is a float number [lambda] (=[1.0] by default). If distribution is ‘chi2’ then dparams is an integer number [k] (=[1] by default).

quantileslist, default=[0.25, 0.75]

Pair of quantiles to use when fitting the Q-Q line.

groupstr

Grouping parameter. If it is specified and color-parameters isn’t then different groups will has different colors.

show_legendbool, default=True

False - do not show legend.

colorstr

Color of a points.

fillstr

Color to paint shape’s inner points. Is applied only to the points of shapes having inner points.

alphafloat, default=0.5

Transparency level of a points. Understands numbers between 0 and 1.

sizefloat, default=3.0

Size of the points.

shapeint

Shape of the points.

line_colorstr, default=’#FF0000’

Color of the fitting line.

line_sizefloat, default=0.75

Width of the fitting line.

linetypeint or str

Type of the fitting line. Codes and names: 0 = ‘blank’, 1 = ‘solid’, 2 = ‘dashed’, 3 = ‘dotted’, 4 = ‘dotdash’, 5 = ‘longdash’, 6 = ‘twodash.

Returns
PlotSpec

Plot object specification.

Notes

The Q-Q plot is used for comparing two probability distributions (sample and theoretical or two sample) by plotting their quantiles against each other.

If the two distributions being compared are similar, the points in the Q-Q plot will approximately lie on the straight line.

Examples

1import numpy as np
2from lets_plot.bistro.qq import qq_plot
3from lets_plot import *
4LetsPlot.setup_html()
5n = 100
6np.random.seed(42)
7x = np.random.normal(0, 1, n)
8qq_plot(data={'x': x}, sample='x')