%useLatestDescriptors
%use dataframe
%use lets-plot
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.9.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.5.1.
var mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv")
mpg.head(3)
DataFrame: rowsCount = 3, columnsCount = 12
untitled | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | audi | a4 | 1.800000 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact |
2 | audi | a4 | 1.800000 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact |
3 | audi | a4 | 2.000000 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact |
val hwy = "hwy"
val cty = "cty"
val drv = "drv"
geomQQ()
and geomQQLine()
functions.¶letsPlot(mpg.toMap()) {sample = hwy} +
geomQQ(size = 5, alpha = .3) +
geomQQLine(size = 1) +
ggtitle("Distribution of highway miles per gallon",
"Comparison of sample quantiles with normal distribution quantiles")
geomQQ()
and geomQQ2Line()
functions.¶letsPlot(mpg.toMap()) {x = cty; y = hwy} +
geomQQ2(size = 5, alpha = .3) +
geomQQ2Line(size = 1) +
ggtitle("City miles vs. highway miles (per gallon)",
"Comparison of quantiles of two sample distributions")
qqPlot()
function¶qqPlot(mpg.toMap(), sample = hwy) +
ggtitle("Distribution of highway miles per gallon",
"Comparison of sample quantiles with normal distribution quantiles")
qqPlot(mpg.toMap(), x = cty, y = hwy) +
ggtitle("City miles vs. highway miles (per gallon)",
"Comparison of quantiles of two sample distributions")
The distribution
parameter of the qq_plot()
function.
val p1 = qqPlot(mpg.toMap(), hwy, distribution = "norm", quantiles = .1 to .9) +
ggtitle("Normal distribution")
val p2 = qqPlot(mpg.toMap(), hwy, distribution = "uniform", quantiles = .1 to .9) +
ggtitle("Uniform distribution")
val p3 = qqPlot(mpg.toMap(), hwy, distribution = "t", quantiles = .1 to .9) +
ggtitle("Student's t-distribution distribution")
val p4 = qqPlot(mpg.toMap(), hwy, distribution = "exp", quantiles = .1 to .9) +
ggtitle("Exponential distribution")
gggrid(listOf(p1, p2, p3, p4), 2, 400, 250)
letsPlot(mpg.toMap()) {x = cty; y = hwy; color = drv} +
geomLine(stat = Stat.qq2()) +
geomPoint(stat = Stat.qq2(), shape = 15) +
geomLine(stat = Stat.qq2Line(), color = "#636363", linetype = 5) +
facetGrid(x = drv, scales = "free") +
xlab("cty quantiles") + ylab("hwy quantiles")