%useLatestDescriptors
%use lets-plot
// Create a random density plot and save it in a variable "p".
val rand = java.util.Random(123)
val n = 400
val data = mapOf (
"rating" to List(n/2) { rand.nextGaussian() } + List(n/2) { rand.nextGaussian() * 1.5 + 1.5 },
"cond" to List(n/2) { "A" } + List(n/2) { "B" }
)
var p = lets_plot(data) +
geom_density { x = "rating"; color = "cond" } + ggsize(500, 250)
import java.io.File
ggsave(p, "density.png")
/Users/Igor/Work_misc/jupyter/lets-plot-kotlin/examples/jupyter-notebooks/lets-plot-images/density.png
HTML("<img src=\"lets-plot-images/density.png\" width=500 height=600>")
ggsave(p, "density.svg")
/Users/Igor/Work_misc/jupyter/lets-plot-kotlin/examples/jupyter-notebooks/lets-plot-images/density.svg
HTML(File("lets-plot-images/density.svg").readText())
ggsave(p, "density.html")
/Users/Igor/Work_misc/jupyter/lets-plot-kotlin/examples/jupyter-notebooks/lets-plot-images/density.html
HTML(File("lets-plot-images/density.html").readText())