Skip to content
Span Chart

Span Chart

span_chart() over named columns of a dataframe_mojo DataFrame (#743). Each argument names a column instead of holding the values.

Span Chart

Usage

from dataviz import span_chart
from dataviz import save

def main() raises:
    var months: List[String] = [
        "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
    ]
    # Illustrative monthly daily-low and daily-high normals for a
    # continental climate, kept in one unit on the shared axis.
    var temp_low: List[Int] = [-6, -4, 1, 7, 12, 18, 20, 19, 15, 8, 2, -3]
    var temp_high: List[Int] = [0, 2, 9, 15, 21, 27, 29, 28, 24, 17, 9, 2]

    var c = span_chart(
        months,
        temp_low,
        temp_high,
        title="Illustrative Chicago Monthly Temperature Range",
        x_title="Month",
        y_title="Temperature (°C)",
    )
    save(c, "docs/src/examples/out_span_chart.svg")

See Data shapes for shared input conventions.

Args:

  • df: The frame to read.
  • categories: The string column for this channel.
  • low: The numeric column for this channel.
  • high: The numeric column for this channel.
  • theme: See the list overload.
  • width: See the list overload.
  • height: See the list overload.
  • title: See the list overload.
  • subtitle: See the list overload.
  • x_title: See the list overload.
  • y_title: See the list overload.

Related

Related charts: Gantt · Streamgraph

Relevant API: span_chart