%useLatestDescriptors
%use lets-plot
%use krangl
var mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv")
mpg.head(3)
manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class | |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | audi | a4 | 1.8 | 1999 | 4 | auto(l5) | f | 18 | 29 | p | compact |
2 | audi | a4 | 1.8 | 1999 | 4 | manual(m5) | f | 21 | 29 | p | compact |
3 | audi | a4 | 2.0 | 2008 | 4 | manual(m6) | f | 20 | 31 | p | compact |
Shape: 3 x 12.
val p = letsPlot(mpg.toMap()) + theme(axisTitleX="blank")
val boxPlot = p +
geomBoxplot(color="#579673", fill="#9AC0B3", size=1.5) {
x = asDiscrete("class", order=1, orderBy="..middle..")
y = "hwy"
} +
ggsize(750, 300)
boxPlot + ggtitle("Default")
boxPlot + ggtitle("Flipped") + coordFlip()
val barPlot = p +
geomBar(size=1.5, alpha=0.7, width=0.7) {
x = asDiscrete("manufacturer", orderBy="..count..")
fill = "class"
color = "class"
} +
ggsize(800, 300)
barPlot + ggtitle("Default")
barPlot + ggtitle("Flipped") + coordFlip()