Skip to content
Continuous Legend Size

Continuous Legend Size

Use this when: You need to enlarge a continuous legend’s gradient bar.

Continuous Legend Size

Usage

from dataviz import Plot, save
from dataviz.core.theme import Theme


def main() raises:
    var x: List[Float64] = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
    var y: List[Float64] = [12.0, 18.0, 15.0, 22.0, 19.0, 25.0, 21.0, 28.0]
    var temperature: List[Float64] = [
        58.0,
        61.0,
        64.0,
        70.0,
        74.0,
        79.0,
        82.0,
        88.0,
    ]

    var plot = (
        Plot()
        .size(900, 600)
        .mark_point()
        .encode(x=x, y=y, color=temperature)
        .labels(title="Readings by Temperature")
        .theme(
            Theme(
                continuous_legend_bar_width=28, continuous_legend_bar_height=220
            )
        )
    )
    save(plot, "docs/src/examples/out_continuous_legend_size.svg")

Related

Related recipes: Legend Sizing · Bullet Styling

Relevant API: Theme · OutputFormat