kandy 0.8.0-RC1 Help

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) } }
Default Point Plot
mpgDf.plot { points { x(displ) y(hwy) color(drv) } layout.title = "The plot title using 'layout.title'" }
Plot with Title
mpgDf.plot { points { x(displ) y(hwy) color(drv) } layout { title = "The plot title using 'Layout context'" } }
Plot with Title
mpgDf.plot { points { x(displ) y(hwy) color(drv) } layout { title = "The plot title" subtitle = "The plot subtitle" } }
Plot with Title and Subtitle
mpgDf.plot { points { x(displ) y(hwy) color(drv) } layout { title = "The plot title" subtitle = "The plot subtitle" caption = "The plot caption" } }
Plot with Title, Subtitle, and 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 } } } }
Titles Color
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 } } } } }
Color and Font Face for Titles
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") } } } } }
Title, Subtitle and Caption Color
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 } } } } }
Two Lines Title
mpgDf.plot { points { x(displ) y(hwy) color(cty) { legend.name = "City mileage" } symbol(drv) { legend.name = "Drive type" } size = 4.0 } }
Legend Name
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 } }
Position Legend
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 } }
Two Lines Legend Name
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 } }
Bottom Two Lines Legend Name
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 } }
Type of Legend
Last modified: 05 February 2024