Skip to content
Lollipop

Lollipop

A lollipop chart.

Lollipop

Usage

from dataviz_mojo import lollipop
from dataviz_mojo.plot import save
from dataviz_mojo.theme import Theme
from dataviz_mojo.colors import TEAL

def main() raises:
    var countries: List[String] = [
        "USA", "China", "Japan", "Germany", "India",
        "UK", "France", "Italy", "Brazil", "Canada",
    ]
    var gdp: List[Float64] = [27.4, 17.8, 4.2, 4.1, 3.7, 3.3, 3.0, 2.2, 2.1, 2.1]

    var c = lollipop(countries, gdp, theme=Theme(mark_color=TEAL))
    save(c, "docs/src/examples/out_lollipop.svg")

Args:

  • categories: One stem-and-point per entry, in the given order.
  • values: Each entry’s value; negative values extend below the zero baseline automatically, the same as bar().
  • theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – see Theme’s docstring.
  • width: Pixel width of the returned Plot (.size()).
  • height: Pixel height of the returned Plot (.size()).
  • title: The chart’s title, shown above the plot.
  • subtitle: A secondary line shown under the title.
  • x_title: The x-axis caption.
  • y_title: The y-axis caption.