%useLatestDescriptors %use lets-plot %use dataframe LetsPlot.getInfo() var mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv") mpg.head(3) val hwy = "hwy" val cty = "cty" val drv = "drv" 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") 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(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") 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")