Theming

Customize a theme for default plot characteristics

Use KoalaPlotTheme to customize default settings used for Koala Plot visual elements. Use it just like MaterialTheme: wrap your content in a call to the Composable KoalaPlotTheme, setting any function arguments desired.

The below exampleshows changing the color of the axes from light gray to black, and removing the rendering of minor ticks.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
    XYGraph(
        rememberFloatLinearAxisModel(data.autoScaleXRange()),
        rememberFloatLinearAxisModel(data.autoScaleYRange()),
        modifier = Modifier.weight(0.5f)
    ) {
        LinePlot(
            data,
            lineStyle = LineStyle(SolidColor(Color.Blue))
        )
    }

    KoalaPlotTheme(axis = KoalaPlotTheme.axis.copy(color = Color.Black, minorGridlineStyle = null)) {
        XYGraph(
            rememberFloatLinearAxisModel(data.autoScaleXRange()),
            rememberFloatLinearAxisModel(data.autoScaleYRange()),
            modifier = Modifier.weight(0.5f)
        ) {
            LinePlot(
                data,
                lineStyle = LineStyle(SolidColor(Color.Blue))
            )
        }
    }
/examples/src/jvmMain/kotlin/io/github/koalaplot/example/Theming1.kt

Theming


Last modified December 1, 2023: Add content sections. (c050f1f)