The stroke
and the color
aesthetics respectively set line width and line color of the pie sector arcs.
The strokeSide
parameter - "inner", "outer"(def), "both" - specifies where to show the arc.
By default stroke
is 0, thus no arc is shown regardless of the value of strokeSide
parameter.
Parameters spacerWidth
and spacerColor
define lines between sectors.
The default is a narrow segment of the same color as the plot background.
%useLatestDescriptors
%use lets-plot
%use dataframe
LetsPlot.getInfo()
Lets-Plot Kotlin API v.4.4.2. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.0.0.
val mpg = DataFrame.readCSV("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")
mpg.head(3)
DataFrame: rowsCount = 3, columnsCount = 12
letsPlot(mpg.toMap()) +
geomPie(size = 20) {
fill = "class"
} +
themeVoid()
stroke
and color
¶val palettes = scaleFillBrewer(palette = "Pastel2") +
scaleColorBrewer(palette = "Set2")
letsPlot(mpg.toMap()) +
geomPie(size = 20, stroke = 7) {
fill = "class"
color = "class"
} +
palettes +
themeVoid()
strokeSide
¶Note: stroke=7
is added to parameters in order to make arks visible.
val p = letsPlot(mpg.toMap()) {
fill = "class"
color = "class"
} + palettes + themeVoid()
gggrid(listOf(
p + geomPie(hole = 0.3, stroke = 7) + ggtitle("Outer stroke (Default)"),
p + geomPie(hole = 0.3, stroke = 7, strokeSide = "Inner") + ggtitle("Inner stroke"),
p + geomPie(hole = 0.3, stroke = 7, strokeSide = "both") + ggtitle("Inner & outer stroke")
)) + ggsize(1000, 200)
spacerWidth
and spacerColor
¶"Spacer" is a thin line separating the pie' slices.
You can adjust width and color of spacers.
letsPlot(mpg.toMap()) +
geomPie(size = 20, hole = 0.3, spacerWidth = 4, spacerColor = "light-gray") {
fill = "class"
} +
themeVoid()
Spacers are not shown for exploded sectors.
val mpg2 = mpg.add("explode") { if(`class` == "pickup") 0.2 else 0.0}
mpg2.head(2)
DataFrame: rowsCount = 2, columnsCount = 13
letsPlot(mpg2.toMap()) +
geomPie(size = 20, hole = 0.3,
stroke = 2, color = "black",
strokeSide = "both",
spacerWidth = 4, spacerColor = "light-gray") {
fill = "class"
explode = "explode"
} +
themeVoid()