Skip to content
Error Bar Cap Width

Error Bar Cap Width

Use this when: You need to narrow error-bar caps for closely spaced points.

Error Bar Cap Width

Usage

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


def main() raises:
    var x: List[Float64] = [1.0, 1.4, 1.8, 2.2, 2.6, 3.0, 3.4, 3.8]
    var y: List[Float64] = [10.0, 11.5, 10.8, 13.0, 12.2, 14.5, 13.8, 15.0]
    var err: List[Float64] = [0.8, 1.0, 0.6, 1.2, 0.9, 1.1, 0.7, 1.0]

    var plot = (
        Plot()
        .mark_point()
        .encode(x=x, y=y, y_err=err)
        .labels(
            title="Closely Spaced Measurements",
            subtitle="Narrower error-bar caps avoid visual collisions",
        )
        .theme(Theme(error_bar_cap_width=2.0))
    )
    save(plot, "docs/src/examples/out_error_bar_cap_width.svg")

Related

Related recipes: Error Bars on a Line · Bubble Size

Relevant API: Plot encodings