stat_quantile ¶
stat_quantile(
mapping: FeatureSpec | None = None,
*,
data: PlotData | None = None,
geom: str | None = None,
position: Position | None = None,
show_legend: bool | None = None,
inherit_aes: bool | None = None,
tooltips: Tooltips | None = None,
quantiles: float | Sequence[float] | None = None,
formula: str | None = None,
method: str | None = None,
na_rm: bool | None = None,
**other_args: Any,
) -> FeatureSpec
Quantile regression lines of y on x (stat="quantile", ggplot2).
Computes ..quantile... stat_quantile(...) is
geom_quantile(stat="quantile", ...); another geom draws the same rows.
Parameters:
-
mapping(FeatureSpec, default:None) –Aesthetic mapping from
aes():x,y(required),color,group. -
data(DataFrame or dict, default:None) –Layer data; inherits the plot data when None.
-
geom(str, default:None) –Geom that draws the computed rows, by name;
"quantile"when None. -
position(str or FeatureSpec, default:None) –Position adjustment: a name such as
"identity"or aposition_*()spec. -
show_legend(bool, default:None) –False hides this layer from the legend.
-
inherit_aes(bool, default:None) –False ignores the plot's default mapping for this layer.
-
tooltips(FeatureSpec or list of str, default:None) –Tooltip content:
layer_tooltips(), a list of column names, or"none". -
quantiles(float or list of float, default:[0.25, 0.5, 0.75]) –Probabilities strictly between 0 and 1, one line each.
-
formula(str, default:"y ~ x") –Only the linear
"y ~ x"is supported. -
method(str, default:"rq") –Only
"rq"is supported. -
na_rm(bool, default:None) –True removes rows with missing values silently; otherwise with a warning.
-
**other_args(Any) –Options of the geom and constant aesthetics such as
color="red".
Returns:
-
FeatureSpec–The layer.
Raises:
-
SpecError–If
formulaormethodasks for another model.
Examples:
>>> from ggrust import *
>>> data = {"x": [1, 2, 3, 4, 5, 6, 7, 8], "y": [1, 3, 2, 5, 4, 7, 5, 9]}
>>> plot = ggplot(data, aes("x", "y")) + geom_point() + stat_quantile(quantiles=[0.1, 0.9])