"boxplotOutlier"
Statistics¶Computes outlier values on boxplot chart but can be used in alternative visualizations as well:
stat = Stat.boxplotOutlier()
%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.
val mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg.head(3)
DataFrame: rowsCount = 3, columnsCount = 12
val p = letsPlot(mpg.toMap()) { y = "hwy" } + scaleColorViridis(option = "magma", end = 0.8) + ggsize(700, 400)
// Ordering by variable "..middle.." when using stat "boxplot" or "boxplotOutlier".
val classByMiddle = asDiscrete("class", orderBy = "..middle..", order = 1)
// Equivalent ordering by variable "..y.." when using `statSummary()`.
val classByY = asDiscrete("class", orderBy = "..y..", order = 1)
p + geomBoxplot() { x = classByMiddle; color = "..middle.." }
Use stat = Stat.boxplotOutlier()
.
val outliers = geomPoint(stat = Stat.boxplotOutlier()) { x = classByMiddle; color = "..middle.." }
p + outliers
val ribbon1 = geomRibbon(stat = Stat.boxplot()) { x = classByMiddle; ymin = "..ymin.."; ymax = "..ymax.." }
val ribbon2 = geomRibbon(stat = Stat.boxplot()) { x = classByMiddle; ymin = "..lower.."; ymax = "..upper.." }
val midPoints = statSummary(fn = "mq", geom = Geom.point(), shape = 15, size = 6) { x = classByY; color = "..y.." }
p + ribbon1 + ribbon2 + midPoints + outliers + labs(color="Middle")