Text¶

In [1]:
%useLatestDescriptors
%use lets-plot
In [2]:
import org.jetbrains.letsPlot.intern.Plot
import org.jetbrains.letsPlot.intern.Feature
In [3]:
fun docsDarkTheme(): Feature {
    val bgColor = "#19191c"
    return theme(
        plotBackground = elementRect(fill = bgColor),
        geom = elementGeom(pen = "white", paper = bgColor)
    ) + flavorHighContrastDark()
}

Font Family¶

In [4]:
fun getFontFamilyPlot(): Plot {
    val families = listOf("sans", "serif", "mono")
    val dataMap = mapOf(
        "y" to (0 until families.size).toList(),
        "f" to families
    )
    return letsPlot(dataMap) +
        geomLabel(x = 0, size = 1, sizeUnit = "y")
            { y = "y"; label = "f"; family = "f" } +
        scaleYReverse(limits = Pair(-0.5, families.size - 0.5)) +
        ggsize(200, 400) +
        themeVoid()
}
In [5]:
val familyPlot = getFontFamilyPlot()
ggsave(familyPlot, "aesthetics_font_family.png")
familyPlot
Out[5]:
sans serif mono
In [6]:
val familyPlotDark = getFontFamilyPlot() + docsDarkTheme()
ggsave(familyPlotDark, "aesthetics_font_family_dark.png")
familyPlotDark
Out[6]:
sans serif mono

Font Face¶

In [7]:
fun getFontFacePlot(): Plot {
    val faces = listOf("plain", "bold", "italic", "bold italic")
    val dataMap = mapOf(
        "y" to (0 until faces.size).toList(),
        "f" to faces
    )
    return letsPlot(dataMap) +
        geomLabel(x = 0, size = 1, sizeUnit = "y")
            { y = "y"; label = "f"; fontface = "f" } +
        scaleYReverse(limits = Pair(-0.5, faces.size - 0.5)) +
        ggsize(300, 400) +
        themeVoid()
}
In [8]:
val facePlot = getFontFacePlot()
ggsave(facePlot, "aesthetics_font_face.png")
facePlot
Out[8]:
plain bold italic bold italic
In [9]:
val facePlotDark = getFontFacePlot() + docsDarkTheme()
ggsave(facePlotDark, "aesthetics_font_face_dark.png")
facePlotDark
Out[9]:
plain bold italic bold italic