Skip to content
Horizontal Lollipop

Horizontal Lollipop

Use this when: You need to draw a lollipop chart with categories running top-to-bottom and stems extending left-to-right instead of the default vertical layout.

Horizontal Lollipop

Usage

from dataviz import Plot, save


def main() raises:
    var languages: List[String] = [
        "Python",
        "JavaScript",
        "TypeScript",
        "Rust",
        "Mojo",
    ]
    var stars_thousands: List[Int] = [62, 98, 100, 92, 24]

    var plot = (
        Plot()
        .mark_lollipop(horizontal=True)
        .encode_categorical(x=languages, y=stars_thousands)
        .labels(title="GitHub Stars by Language", x_title="Stars (thousands)")
    )
    save(plot, "docs/src/examples/out_horizontal_lollipop.svg")

Related

Related recipes: Horizontal Stacked Bar · Horizontal Box

Relevant API: Plot · Theme