%useLatestDescriptors
%use lets-plot
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.5.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.1.0.
These color scales now work in the HCL color space (earlier - HLV) and,
with adjusted default values, are now exact equivalent of their ggplot2 counterparts.
val data = mapOf(
"x" to ('A'..'F').toList()
)
letsPlot(data) +
geomBoxplot(stat = Stat.identity, lower = 25, middle = 50, upper = 75, ymin = 0, ymax = 100) {
x = "x"; fill = "x"
} +
scaleFillHue()
val grad = mapOf(
"x" to (0..255).toList()
)
val p = letsPlot(grad) +
geomTile(size = 1, showLegend = false) { x = "x"; fill = "x"; color = "x" } +
coordCartesian() +
ggsize(800, 100) +
themeVoid()
p + scaleFillHue() +
scaleColorHue()
All gradient color scales (other than hue) now work in the CIELAB color space (earlier - HLV) and,
produce smoother gradients than before.
scaleColorGradient()
:¶p + scaleFillGradient(low = "#00FF00", high = "#FF0000") +
scaleColorGradient(low = "#00FF00", high = "#FF0000")
scaleColorGradientN()
:¶p + scaleFillGradientN(colors = listOf("#00FF00", "#FF0000", "#0000FF")) +
scaleColorGradientN(colors = listOf("#00FF00", "#FF0000", "#0000FF"))
scaleColorGrey()
:¶p + scaleColorGrey(start = 0.1, end = 0.9) +
scaleFillGrey(start = 0.1, end = 0.9)
scaleColorViridis()
¶val options = listOf("magma", "inferno", "plasma", "viridis", "cividis", "turbo", "twilight")
val plots = options.map { op ->
p + scaleFillViridis(option = op) + scaleColorViridis(option = op) + ggtitle(op)
}
gggrid(plots, ncol=2) + ggsize(900, 600)
hstart
now works with discrete data:¶letsPlot(data) +
geomBoxplot(stat = Stat.identity, lower = 25, middle = 50, upper = 75, ymin = 0, ymax = 100) {
x = "x"; fill = "x"
} +
scaleFillHue(hstart = 180)
l
now correctly controls lightness:¶letsPlot(data) +
geomBoxplot(stat = Stat.identity, lower = 25, middle = 50, upper = 75, ymin = 0, ymax = 100) {
x = "x"; fill = "x"
} +
scaleFillHue(hstart = 180, c = 95, l = 95) +
ggtitle("scaleFillHue(hstart = 180, c = 95, l = 95)")