Title, subtitle, and caption
val mpgDf =
DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-kotlin/master/docs/examples/data/mpg.csv")
mpgDf.head()
untitled | manufacturer | model | displ | year | cyl | trans | drv | cty | hwy | fl | class |
---|---|---|---|---|---|---|---|---|---|---|---|
1 | audi | a4 | 18 | 1999 | 4 | auto\(l5\) | f | 18 | 29 | p | compact |
2 | audi | a4 | 18 | 1999 | 4 | manual\(m5\) | f | 21 | 29 | p | compact |
3 | audi | a4 | 2 | 2008 | 4 | manual\(m6\) | f | 20 | 31 | p | compact |
4 | audi | a4 | 2 | 2008 | 4 | auto\(av\) | f | 21 | 30 | p | compact |
5 | audi | a4 | 28 | 1999 | 6 | auto\(l5\) | f | 16 | 26 | p | compact |
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout.title = "The plot title using 'layout.title'"
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout {
title = "The plot title using 'Layout context'"
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout {
title = "The plot title"
subtitle = "The plot subtitle"
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout {
title = "The plot title"
subtitle = "The plot subtitle"
caption = "The plot caption"
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout {
title = "The plot title"
subtitle = "The plot subtitle"
caption = "The plot caption"
style {
global.title {
color = Color.BLUE
}
}
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout {
title = "The plot title"
subtitle = "The plot subtitle"
caption = "The plot caption"
style {
global {
text {
fontFace = FontFace.ITALIC
}
title {
fontFace = FontFace.ITALIC
}
}
plotCanvas {
title {
color = Color.BLUE
}
subtitle {
fontFace = FontFace.ITALIC
}
caption {
fontFace = FontFace.ITALIC
}
}
}
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout {
title = "The plot title"
subtitle = "The plot subtitle"
caption = "The plot caption"
style {
plotCanvas {
title {
color = Color.BLUE
}
subtitle {
color = Color.RED
}
caption {
color = Color.named("dark_green")
}
}
}
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(drv)
}
layout {
title = "The plot title:\nFuel efficiency for most popular models of car"
subtitle = "The plot subtitle:\nPoints are colored by the type of drive train"
caption = "The plot caption:\nmpg dataset"
style {
plotCanvas {
subtitle {
color = Color.GREY
}
}
}
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(cty) { legend.name = "City mileage" }
symbol(drv) { legend.name = "Drive type" }
size = 4.0
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(cty) { legend.name = "City mileage" }
symbol(drv) { legend.name = "Drive type" }
size = 4.0
}
layout.style {
legend.position = LegendPosition.Bottom
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(cty) { legend.name = "City mileage\n(mpg)" }
symbol(drv) { legend.name = "Drive type\n(front/4/rear wheel)" }
size = 4.0
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(cty) { legend.name = "City mileage\n(mpg)" }
symbol(drv) { legend.name = "Drive type\n(front/4/rear wheel)" }
size = 4.0
}
layout.style {
legend.position = LegendPosition.Bottom
}
}
mpgDf.plot {
points {
x(displ)
y(hwy)
color(cty) { legend.name = "City mileage\n(mpg)" }
symbol(drv) {
legend {
type = LegendType.DiscreteLegend(nRow = 3)
name = "Drive type\n(front/4/rear wheel)"
}
}
size = 4.0
}
layout.style {
legend.position = LegendPosition.Bottom
}
}
Last modified: 05 February 2024