Theming Plots

Theming controls colors, fills, and other aspects of the visual appearance of plots. There are two concepts in Chartreuse's theme system:

Themes

Themes are found within the chartreuse.theme package. Most users will apply a theme to a whole plot, using a PlotTheme. There are a small number of predefined PlotThemes available in Chartreuse:

To apply a theme to a Plot, pass it to the draw method. For example, instead of calling

aPlot.draw(640, 480)

call

aPlot.draw(640, 480, PlotTheme.base16.defaultLight)

Themeable Values

Where a value in Chartreuse can be themed it is represented as a Themeable value. For example, Curve contains a LayoutTheme which in turn contains Themeable values for strokeColor, fillColor, and so on.

A Themeable value specifies either a Default, which will be overriden by the theme's value, if there is one, or an Override, which will override the theme's value. So, for example, if a Themeable strokeColor is Themeable.Default(Color.red), this value will be overriden by the theme's strokeColor. However, if the value is Themeable.Override(Color.red) it will override the theme.

When changing Themeable values it's usually the case you want to override the theme. Here's an example creating a Line layout and overriding the theme with custom stroke color and width.

Line
  .default[Point]
  .forThemeable(theme =>
    theme
      .withStrokeColor(Themeable.Override(Some(Color.darkBlue)))
      .withStrokeWidth(Themeable.Override(3.0))
  )

Here are examples of some of the available themes.

Default Theme

BMH Theme

FiveThirtyEight Theme

Base16 Default Light Theme

Base16 Ocean Theme