Residual Plot
residplot() over named columns of a dataframe_mojo DataFrame (#743). Each argument names a column instead of holding the values. The axis titles default to the x and y column names.
Usage
from dataviz import residplot, save
def main() raises:
# Illustrative braking distance (m) against speed (km/h). The
# true relationship is quadratic, so a straight-line fit
# leaves a U of residuals: positive at both ends, negative in
# the middle -- the shape that says "not linear".
var speed = List[Float64]()
var distance = List[Float64]()
for i in range(12):
var v = 20.0 + 10.0 * Float64(i)
speed.append(v)
distance.append(0.0065 * v * v + 0.2 * v)
var c = residplot(
speed,
distance,
title="Residuals of a Linear Fit to Braking Distance",
x_title="Fitted distance (m)",
y_title="Residual (m)",
)
save(c, "docs/src/examples/out_residplot.svg")See Data shapes for shared input conventions.
Args:
df: The frame to read.x: The numeric column for this channel.y: The numeric column for this channel.theme: See the list overload.width: See the list overload.height: See the list overload.title: See the list overload.subtitle: See the list overload.x_title: See the list overload.y_title: See the list overload.
Related
Related charts: Estimate Points · Joint Plot
Relevant API: residplot