%useLatestDescriptors
%use lets-plot
%use dataframe
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.8.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.4.1.
val iris = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/iris.csv")
iris.head()
DataFrame: rowsCount = 5, columnsCount = 5
sepal_length | sepal_width | petal_length | petal_width | species |
---|---|---|---|---|
5.100000 | 3.500000 | 1.400000 | 0.200000 | setosa |
4.900000 | 3.000000 | 1.400000 | 0.200000 | setosa |
4.700000 | 3.200000 | 1.300000 | 0.200000 | setosa |
4.600000 | 3.100000 | 1.500000 | 0.200000 | setosa |
5.000000 | 3.600000 | 1.400000 | 0.200000 | setosa |
val irisData = iris.toMap()
val mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv")
mpg.head()
DataFrame: rowsCount = 5, 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 |
4 | audi | a4 | 2.000000 | 2008 | 4 | auto(av) | f | 21 | 30 | p | compact |
5 | audi | a4 | 2.800000 | 1999 | 6 | auto(l5) | f | 16 | 26 | p | compact |
val mpgData = mpg.toMap()
val p = letsPlot(irisData) { x = "sepal_length"; y = "species" }
p + geomAreaRidges()
min_height
parameter¶val data = mapOf(
"x" to listOf(1, 2, 3, 4, 5, 6, 7, 1, 2, 3, 4, 5, 6, 7),
"y" to listOf(-.4, -.4, -.4, -.4, -.4, -.4, -.4, -.8, -.8, -.8, -.8, -.8, -.8, -.8),
"h" to listOf(.4, -.2, .6, -.8, .3, .1, .7, .1, .3, .1, -.6, -.1, -.3, -.1)
)
letsPlot(data) +
geomAreaRidges(stat = Stat.identity, color = "black", fill = "#3182bd", minHeight = -.4) {
x = "x"; y = "y"; height = "h"
}
trim
and tailsCutoff
parameters¶gggrid(
plots = listOf(
p + geomAreaRidges(trim = false, tailsCutoff = null) + ggtitle("Default: trim=false, tailsCutoff=null"),
p + geomAreaRidges(trim = false, tailsCutoff = 0) + ggtitle("trim=false, tailsCutoff=0"),
p + geomAreaRidges(trim = false, tailsCutoff = 3) + ggtitle("trim=false, tailsCutoff=3"),
p + geomAreaRidges(trim = true) + ggtitle("trim=true")
),
ncol = 2,
cellWidth = 400,
cellHeight = 300
)
scale
parameter¶p + geomAreaRidges(scale = 1.5)
val quantiles = listOf(.05, .25, .5, .75, .95)
gggrid(
plots = listOf(
p + geomAreaRidges(quantiles = quantiles, color = "black"),
p + geomAreaRidges(quantiles = quantiles, quantileLines = true, color = "black"),
p + geomAreaRidges(quantiles = quantiles, color = "black", showLegend = false) { fill = "..quantile.." },
p + geomAreaRidges(quantiles = quantiles, quantileLines = true, color = "black", showLegend = false) {
fill = "..quantile.."
}
),
ncol = 2,
cellWidth = 400,
cellHeight = 300
)
p + geomAreaRidges(kernel = "triangular", adjust = .8, quantileLines = true,
color = "#993404", fill = "#fe9929",
tooltips = layerTooltips()
.line("height|@..height..")
.format("@..density..", ".2f")
.line("density|@..density..")
.line("quantile|@..quantile.."))
letsPlot(mpgData) { x = "hwy"; y = asDiscrete("year"); fill = "drv" } +
geomAreaRidges(color = "white", alpha = .5) +
scaleFillBrewer(type = "qual", palette = "Set1") +
facetGrid(x = "drv") +
themeBW() +
flavorDarcula()