All examples
Visualization

Tell a scientific story with Aner Plot

Compose synthetic scientific charts, compare light, dark and company themes, and join values to offline USA and world boundaries.

plot_story.aner
import aner.plot

let weeks = List(1.0, 2.0, 3.0, 4.0, 5.0, 6.0)
let response = List(12.0, 15.0, 14.0, 19.0, 21.0, 23.0)
let reference = List(10.0, 12.0, 13.0, 14.0, 16.0, 17.0)
let company = plot.theme("light").company(
    name: "Example Research",
    background: "#FFFFFF",
    foreground: "#17233B",
    colors: List("#007C91", "#C6601D", "#6950A1")
)
let trend = plot.line(x: weeks, y: response)
    .add_line(x: weeks, y: reference, name: "Reference")
    .title("Response increased across six synthetic observations")
    .labels(x: "Week", y: "Response (arbitrary units)")
    .caption("Synthetic sequences; reference values are supplied, not fitted.")
    .annotate(x: 6.0, y: 23.0, text: "Last observation")
    .theme(company)
    .size(width: 900, height: 560)
trend.show()

plot.scatter(x: weeks, y: response)
    .title("Each point is one supplied observation")
    .labels("Week", "Response (arbitrary units)")
    .theme(plot.theme("dark"))
    .show()

plot.bar(labels: List("Control", "Treatment"), values: List(12.0, 18.0))
    .title("Supplied counts by synthetic group")
    .labels("Group", "Count")
    .caption("Two supplied counts; no automatic aggregation or confidence interval.")
    .theme(company)
    .show()

plot.histogram(values: response, bins: 4)
    .title("Distribution of six synthetic responses")
    .labels("Response (arbitrary units)", "Observed count")
    .caption("Four equal-width bins; counts are not probability density.")
    .theme(plot.theme("light"))
    .show()

plot.box(values: response)
    .title("Observed sample spread")
    .labels("Synthetic sample", "Response (arbitrary units)")
    .caption("Quartiles and whiskers summarize observations, not confidence intervals.")
    .show()

plot.heatmap(values: List(1.0, 2.0, 3.0, 4.0, 5.0, 6.0), rows: 2, columns: 3)
    .title("Six supplied row-major measurements")
    .labels("Column", "Row")
    .caption("Synthetic cells; color represents the supplied value.")
    .show()

let geometry = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"code\":\"A\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[0,0],[2,0],[2,2],[0,2],[0,0]]]}},{\"type\":\"Feature\",\"properties\":{\"code\":\"B\"},\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[2,0],[4,0],[4,2],[2,2],[2,0]]]}}]}"
plot.choropleth(geojson: geometry, property: "code", keys: List("A", "B"), values: List(12.0, 18.0))
    .title("Two invented regions, joined by String code")
    .caption("Synthetic geometry and values; not real USA or world boundaries.")
    .show()

plot.world(keys: List("USA", "CAN", "FRA"), values: List(12.0, 9.0, 15.0))
    .title("Synthetic values on an offline world map")
    .caption("Synthetic values; boundaries: Natural Earth 1:110m, admin-0 codes.")
    .show()

plot.usa(keys: List("CA", "CO", "NY", "TX"), values: List(18.0, 12.0, 15.0, 9.0))
    .title("Synthetic values for four USA states")
    .caption("Synthetic values; other states have no data, not zero. Natural Earth boundaries.")
    .theme(company)
    .show()

plot.map(region: "chile", keys: List("CL-RM", "CL-VS", "CL-NB"), values: List(12.0, 9.0, 7.0))
    .title("Synthetic values in three Chilean regions")
    .caption("Synthetic index; Natural Earth 2022 snapshot; absent regions have no data.")
    .show()

plot.map(region: "argentina", keys: List("AR-B", "AR-C", "AR-X"), values: List(11.0, 8.0, 10.0))
    .title("Synthetic values in Argentine provinces and city")
    .caption("Synthetic index; Natural Earth 2022 snapshot; province and city use distinct keys.")
    .show()

plot.map(region: "europe", keys: List("FRA", "DEU", "ESP", "ITA", "GBR"), values: List(12.0, 15.0, 9.0, 10.0, 14.0))
    .title("Synthetic country values in Europe")
    .caption("Synthetic index; Natural Earth 2022 snapshot; Europe is broader than the EU.")
    .show()

plot.map(region: "usa.co.counties", keys: List("08013"), values: List(12.0))
    .title("Synthetic value for Boulder County, Colorado")
    .caption("Synthetic index; Census 2025 county GEOID 08013; distinct from Boulder city.")
    .show()

plot.map(region: "usa.ca.counties", keys: List("06037", "06075", "06085"), values: List(18.0, 12.0, 9.0))
    .title("Synthetic values for three California counties")
    .caption("Synthetic index; Census 2025 counties: Los Angeles, San Francisco and Santa Clara.")
    .show()

plot.map(region: "usa.co.places", keys: List("0807850"), values: List(8.0))
    .focus("0807850")
    .title("Synthetic value for Boulder city, Colorado")
    .caption("Synthetic index; Census 2025 place GEOID 0807850; distinct from Boulder County.")
    .show()

plot.map(region: "usa.ca.places", keys: List("0667000", "0644000", "0655282"), values: List(12.0, 18.0, 9.0))
    .focus("0655282")
    .title("Palo Alto in the California city dataset")
    .caption("Synthetic index; Census 2025 places; Palo Alto focus retains the full dataset color range.")
    .show()

Run step by step in VS Code.

The notebook separates observations and chart construction into cells. It opens with empty outputs and shared variables. Map cells state which optional local packs they need.

  1. Install a compatible native Aner executable and VS Code extension using the editor guide. Chart construction and interactive geographic navigation require the Aner 0.0.3 or newer runtime and editor.
  2. Download the .anernb notebook and open it in your VS Code project. If it appears as JSON, choose Reopen Editor With… → Aner Notebook.
  3. Select the Aner — notebook kernel and keep Shared variables active. Run code cells from top to bottom, or choose Run All. Later cells reuse observations and chart values from earlier cells. Run cells that need no pack before trying the optional geographic map.
  4. Read the figures below their producing cells. In geographic outputs, use local navigation or selection controls to inspect a region. Drag to pan and zoom to reveal crowded labels. Static SVG exports retain the initial view. Source observations, units and limitations remain in each caption.

After changing an earlier cell, rerun its dependent cells. Use Aner: Restart Notebook Session, then Run All, for a clean experiment. Saved outputs are historical; reopening the file starts without live variables. The notebook guide explains session state, inspection, and runtime controls.

Make it your experiment.

Use Aner 0.0.3 or newer. Save this program as examples/plot_story.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/plot_story.aner
aner run examples/plot_story.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Requires Aner 0.0.4 or newer and a matching VS Code extension for notebook display. Use Aner 0.0.3 or newer for these chart APIs. Install the matching local world, usa, chile, argentina, europe, usa.co and usa.ca map packs before running the complete source. Use the compatible installed aner command to check and run the source, or open the notebook in VS Code, restart its session and choose Run All. The supplied observations need no external data, network connection or credentials.

Observations are synthetic teaching inputs. Geographic context comes from optional offline boundary packs and does not add street detail or establish observed traffic conditions.

Read the chart and map contracts
Install Aner