Theme
Mojo struct đźˇ
Theme
@memory_only
struct ThemeFields
- background (
Color): The canvas’s fill color, drawn behind everything else. - mark_color (
Color): The default ink a mark draws in – bar fill, line stroke, point fill, … – whenever no data-drivencolor/color_categorieschannel or per-mark override (mark_color_negative, a palette, …) applies instead. - axis_color (
Color): The axis line/tick/frame color. - gridline_color (
Color): Gridline color, drawn whenshow_gridlinesisTrue. - text_color (
Color): The default text color – tick labels, the chart title, and anywhere else no more specific color field (subtitle_color,annotation_color, …) applies. - font_size (
Float64): The base font size, in points, for tick/legend labels – scaled byTheme.scalethe same as every other pixel-sized quantity (see_Scaled’s docstring, plot.mojo). - point_radius (
Float64): The default pixel radius forMark.POINT/EFFECT_SCATTERmarkers, before any data-drivensizechannel overrides it. - line_width (
Float64): The default stroke width, in pixels, forMark.LINE/AREAand every other stroked mark. - margin_left (
Int): Reserved pixel space along the plot’s left edge, before the y-axis’s own tick-label width/margin_bufferare added on top. - margin_right (
Int): Reserved pixel space along the plot’s right edge, before a legend’s own reserved width (if any) is added on top. - margin_top (
Int): Reserved pixel space along the plot’s top edge, before a title/subtitle’s own reserved height (if any) is added on top. - margin_bottom (
Int): Reserved pixel space along the plot’s bottom edge, before an x-axis title’s own reserved height (if any) is added on top. - show_gridlines (
Bool): Whether to draw gridlines at all; defaults toTrue. - color_scale_low (
Color): The low end of the default continuous color gradient (Plot. encode(color=...),Mark.HEATMAP/CORRPLOT/CALENDAR_HEATMAP). - color_scale_mid (
Color): The midpoint of the default continuous color gradient – a deliberate third stop, not a two-color blend; see this struct’s own module docstring for why a plain low/high interpolation reads as a muddy, desaturated middle. - color_scale_high (
Color): The high end of the default continuous color gradient. - size_range_min (
Float64): The smallest pixel radius a data-drivensizechannel maps its column’s minimum value to. - size_range_max (
Float64): The largest pixel radius a data-drivensizechannel maps its column’s maximum value to. - show_legend (
Bool): Whether to draw a legend at all, for every mark that has one; defaults toTrue. - scale (
Float64): Uniformly multiplies every other pixel-sized quantityrender()computes (font size, margins, point radius, line width, tick length, legend layout, …); see this struct’s own module docstring for the full HiDPI-rendering reasoning. - donut_inner_radius_fraction (
Float64): A fraction ([0.0, 1.0)) ofMark.ARC’s outer radius to leave as a hole –0.0(the default) draws an ordinary pie; any positive value draws a donut. - color_by_sign (
Bool): WhetherMark.BARcolors each bar by whether its value is negative (mark_color_negative) or not (mark_color); defaults toFalse(every bar staysmark_color). - mark_color_negative (
Color): The ink for a negative value –Mark.BARwhencolor_by_signisTrue, and unconditionally forMark.WATERFALL/CANDLESTICK, whose falling/down coloring isn’t optional. - bullet_range_color_light (
Color): The lightest end ofMark.BULLET’s grayscale qualitative-range band gradient (lowest range index). - bullet_range_color_dark (
Color): The darkest end ofMark.BULLET’s grayscale qualitative-range band gradient (highest range index). - line_smoothing (
Float64): How muchMark.LINE/AREAcurves through its data points, via a Catmull-Rom-derived spline –0.0(the default) draws plain straight segments;1.0the full curve; must be in[0.0, 1.0]. - title_font_size (
Float64): The chart title’s font size, in points; defaults larger thanfont_sizesince a title reads as a heading. - subtitle_font_size (
Float64): The subtitle’s font size, in points – the same size an axis title uses, both reading as a subordinate label under the title. - subtitle_color (
Color): The subtitle’s dedicated color, distinct fromtext_colorso it recedes as supporting context rather than competing with the title. - axis_title_font_size (
Float64): The x/y-axis title’s font size, in points. - waterfall_total_color (
Color):Mark.WATERFALL’s third color, for a rowencode_waterfall()’sis_totalmarks as a running-total checkpoint – deliberately distinct frommark_color/mark_color_negativesince a total bar is a different kind of thing, not a big increase or decrease. - annotation_color (
Color):Plot.annotate_line()/annotate_vline()/annotate_point()’s color – the reference mark itself and its optional label. - annotation_area_color (
Color):Plot.annotate_area()’s fill – a separate field fromannotation_colorsince a filled band needs real partial opacity to let the mark underneath keep showing through, unlike a line. - font_family (
String): Every_TextRequest’s typeface; defaults to"sans-serif", a generic keyword both the raster (fontconfig) and SVG (CSS) text backends resolve consistently. - title_bold (
Bool): Whether the chart title draws bold; defaults toTrue. The one field in this struct whose default isn’t backward-compatible with pre-existing renders – see this struct’s own module docstring. - waterfall_delta_width_fraction (
Float64): How much of its band a rising/fallingMark.WATERFALLdelta bar occupies; a total bar always spans the full band. - bullet_measure_width_fraction (
Float64): How thickMark.BULLET’s measure bar is relative to its band. - chord_ring_fraction (
Float64): How thickMark.CHORD’s node ring is relative to the outer radius. - radialbar_track_color (
Color): The unfilled background trackMark.RADIALBARsweeps its rings over. - treemap_label_color (
Color): The label color drawn on aMark.TREEMAPleaf rectangle. - halo_alpha (
UInt8): The opacityMark.EFFECT_SCATTERblends each point’s halo at, before flattening it against white. - radar_fill_alpha (
UInt8): The opacityMark.RADARblends each series’ filled polygon at, before flattening it against white – a separate field fromhalo_alphaeven though both default to the same value, so retheming one never silently moves the other. - radialbar_ring_gap_fraction (
Float64): The gap between adjacentMark.RADIALBARrings, as a fraction of each ring’s own slot. - violin_width_fraction (
Float64): How much of its category’s band width aMark.VIOLIN’s peak density maps to, by default (ggplot2’sscale = "width"). - corrplot_bubble_fraction (
Float64): How much of aMark.CORRPLOTcell’s smaller dimension its bubble’s maximum radius (atabs(correlation) == 1.0) fills. - gauge_band_inner_fraction (
Float64):Mark.GAUGE’s color-banded dial ring’s inner radius, as a fraction of the dial’s outer radius. - gauge_needle_fraction (
Float64):Mark.GAUGE’s needle length, as a fraction of the dial’s outer radius. - ridgeline_overlap (
Float64): How far aMark.RIDGELINErow’s curve may rise into the row above it, as a multiple of one row’s own height. - polar_bar_padding (
Float64): The gapMark.POLAR_BARleaves out of each bar’s angular slot, as a fraction of that slot. - polar_grid_rings (
Int): How many evenly spaced concentric gridline ringsMark.POLARdraws. - polar_grid_spokes (
Int): How many straight radial gridline spokesMark.POLARdraws. - radar_grid_rings (
Int): How many concentric gridline ringsMark.RADARdraws. - gauge_start_angle (
Float64):Mark.GAUGE’s dial start angle, in radians (this package’s usual clockwise-from-3-o’clock convention). - gauge_sweep_angle (
Float64):Mark.GAUGE’s total dial sweep, in radians, fromgauge_start_angle. - tick_length (
Int): The pixel length of each axis tick mark. - label_gap (
Int): The pixel gap between a tick mark and its label. - legend_width (
Int): The reserved pixel width for a legend’s swatch-plus-label column, when its dynamic width can’t be computed some other way. - legend_swatch_size (
Int): The pixel size of each legend entry’s color swatch. - legend_row_gap (
Int): The pixel gap between consecutive legend entries. - continuous_legend_bar_width (
Int): The pixel width of a continuous (gradient) legend’s color bar. - continuous_legend_bar_height (
Int): The pixel height of a continuous (gradient) legend’s color bar. - margin_buffer (
Int): Extra breathing-room padding, in pixels, added after a margin’s own tick-label-width/tick-length/label-gap computation. - sankey_node_width (
Float64): The pixel width of eachMark.SANKEYnode column’s bar. - output_format (
OutputFormat): The file formatsave()(plot.mojo) writes when given aPlotand a path, with nocanvas_mojobackend named at the call site – defaults toOutputFormat.SVG(see that struct’s docstring for why vector is the default).render()/render_svg()ignore this field entirely; it only governssave()’s own choice.
Implemented traits
AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable
Methods
__init__
fn def __init__(out self, background: Color = WHITE, mark_color: Color = Color(UInt8(30), UInt8(100), UInt8(180), UInt8(255)), axis_color: Color = Color(UInt8(80), UInt8(80), UInt8(80), UInt8(255)), gridline_color: Color = Color(UInt8(225), UInt8(225), UInt8(225), UInt8(255)), text_color: Color = Color(UInt8(40), UInt8(40), UInt8(40), UInt8(255)), font_size: Float64 = 12, point_radius: Float64 = 3.5, line_width: Float64 = 2, margin_left: Int = Int(60), margin_right: Int = Int(20), margin_top: Int = Int(20), margin_bottom: Int = Int(50), show_gridlines: Bool = True, color_scale_low: Color = Color(UInt8(60), UInt8(110), UInt8(200), UInt8(255)), color_scale_mid: Color = Color(UInt8(235), UInt8(235), UInt8(235), UInt8(255)), color_scale_high: Color = Color(UInt8(220), UInt8(90), UInt8(40), UInt8(255)), size_range_min: Float64 = 3, size_range_max: Float64 = 15, show_legend: Bool = True, scale: Float64 = 1, donut_inner_radius_fraction: Float64 = 0, color_by_sign: Bool = False, mark_color_negative: Color = Color(UInt8(200), UInt8(60), UInt8(60), UInt8(255)), bullet_range_color_light: Color = Color(UInt8(224), UInt8(224), UInt8(224), UInt8(255)), bullet_range_color_dark: Color = Color(UInt8(120), UInt8(120), UInt8(120), UInt8(255)), line_smoothing: Float64 = 0, title_font_size: Float64 = 18, subtitle_font_size: Float64 = 14, subtitle_color: Color = Color(UInt8(110), UInt8(110), UInt8(110), UInt8(255)), axis_title_font_size: Float64 = 14, waterfall_total_color: Color = Color(UInt8(100), UInt8(100), UInt8(100), UInt8(255)), annotation_color: Color = Color(UInt8(150), UInt8(150), UInt8(150), UInt8(255)), annotation_area_color: Color = Color(UInt8(224), UInt8(236), UInt8(246), UInt8(200)), font_family: String = "sans-serif", title_bold: Bool = True, waterfall_delta_width_fraction: Float64 = 0.59999999999999998, bullet_measure_width_fraction: Float64 = 0.34999999999999998, chord_ring_fraction: Float64 = 0.080000000000000002, radialbar_track_color: Color = Color(UInt8(230), UInt8(230), UInt8(230), UInt8(255)), treemap_label_color: Color = Color(UInt8(255), UInt8(255), UInt8(255), UInt8(255)), halo_alpha: UInt8 = UInt8(90), radar_fill_alpha: UInt8 = UInt8(90), radialbar_ring_gap_fraction: Float64 = 0.25, violin_width_fraction: Float64 = 0.40000000000000002, corrplot_bubble_fraction: Float64 = 0.41999999999999998, gauge_band_inner_fraction: Float64 = 0.69999999999999996, gauge_needle_fraction: Float64 = 0.90000000000000002, ridgeline_overlap: Float64 = 1.3, polar_bar_padding: Float64 = 0.20000000000000001, polar_grid_rings: Int = Int(4), polar_grid_spokes: Int = Int(12), radar_grid_rings: Int = Int(4), gauge_start_angle: Float64 = 2.3561944901923448, gauge_sweep_angle: Float64 = 4.7123889803846897, tick_length: Int = Int(5), label_gap: Int = Int(4), legend_width: Int = Int(130), legend_swatch_size: Int = Int(14), legend_row_gap: Int = Int(8), continuous_legend_bar_width: Int = Int(14), continuous_legend_bar_height: Int = Int(100), margin_buffer: Int = Int(8), sankey_node_width: Float64 = 12, output_format: OutputFormat = OutputFormat.SVG)Construct a Theme, overriding any subset of its fields by keyword – every parameter here is one field, same name, same default; see each field’s own docstring above for what it controls rather than this method repeating it, so a change to one never has a second copy elsewhere to fall out of sync.
Args:
- background (
Color) - mark_color (
Color) - axis_color (
Color) - gridline_color (
Color) - text_color (
Color) - font_size (
Float64) - point_radius (
Float64) - line_width (
Float64) - margin_left (
Int) - margin_right (
Int) - margin_top (
Int) - margin_bottom (
Int) - show_gridlines (
Bool) - color_scale_low (
Color) - color_scale_mid (
Color) - color_scale_high (
Color) - size_range_min (
Float64) - size_range_max (
Float64) - show_legend (
Bool) - scale (
Float64) - donut_inner_radius_fraction (
Float64) - color_by_sign (
Bool) - mark_color_negative (
Color) - bullet_range_color_light (
Color) - bullet_range_color_dark (
Color) - line_smoothing (
Float64) - title_font_size (
Float64) - subtitle_font_size (
Float64) - subtitle_color (
Color) - axis_title_font_size (
Float64) - waterfall_total_color (
Color) - annotation_color (
Color) - annotation_area_color (
Color) - font_family (
String) - title_bold (
Bool) - waterfall_delta_width_fraction (
Float64) - bullet_measure_width_fraction (
Float64) - chord_ring_fraction (
Float64) - radialbar_track_color (
Color) - treemap_label_color (
Color) - halo_alpha (
UInt8) - radar_fill_alpha (
UInt8) - radialbar_ring_gap_fraction (
Float64) - violin_width_fraction (
Float64) - corrplot_bubble_fraction (
Float64) - gauge_band_inner_fraction (
Float64) - gauge_needle_fraction (
Float64) - ridgeline_overlap (
Float64) - polar_bar_padding (
Float64) - polar_grid_rings (
Int) - polar_grid_spokes (
Int) - radar_grid_rings (
Int) - gauge_start_angle (
Float64) - gauge_sweep_angle (
Float64) - tick_length (
Int) - label_gap (
Int) - legend_width (
Int) - legend_swatch_size (
Int) - legend_row_gap (
Int) - continuous_legend_bar_width (
Int) - continuous_legend_bar_height (
Int) - margin_buffer (
Int) - sankey_node_width (
Float64) - output_format (
OutputFormat) - self (
Self)
Returns:
Self
default
@staticmethod
fn def default() -> SelfNamed the same way FontSlant.NORMAL-style call sites in this workspace read – Theme.default() rather than relying on every caller remembering that Theme() alone already means the same thing (it does; this is purely for readability at call sites like .theme(Theme.default())).
Returns:
Self