%useLatestDescriptors
%use lets-plot
%use dataframe
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.4.2. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.0.0.
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
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")