Skip to content
Scatter

Scatter

scatter() over named columns of a dataframe_mojo DataFrame (#364). The columns carry their own names, so the axis titles default to them.

Scatter

Usage

from dataviz import scatter
from dataviz import save

def main() raises:
    # Illustrative specifications for current electric vehicles.
    var battery_kwh: List[Float64] = [
        42, 50, 54, 58, 62, 66, 70, 74, 78, 82, 88, 94, 101, 108, 115,
    ]
    var highway_range_km: List[Float64] = [
        255, 292, 318, 305, 354, 381, 365, 419, 445, 432, 487, 516, 548,
        565, 604,
    ]

    var c = scatter(
        battery_kwh,
        highway_range_km,
        title="Illustrative EV Battery Capacity vs. Highway Range",
        x_title="Usable battery capacity (kWh)",
        y_title="Highway range (km)",
    )
    save(c, "docs/src/examples/out_scatter.svg")

See Data shapes for shared input conventions.

Args:

  • df: The frame to read.
  • x: The numeric column for the x axis.
  • y: The numeric column for the y axis.
  • color: Optional column driving color – a palette for a string column, a continuous scale for a numeric one.
  • size: Optional numeric column driving point size.
  • labels: Optional string column drawn above each point.
  • theme: Full styling knobs beyond this function’s own parameters.
  • 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.
  • x_title: The x-axis caption; defaults to x.
  • y_title: The y-axis caption; defaults to y.

Related

Related charts: Line

Relevant API: scatter