Line
Line
A line chart.
Usage
from std.math import sin
from dataviz_mojo import line
from dataviz_mojo.plot import save
from dataviz_mojo.colors import BROWN
from dataviz_mojo.theme import Theme
def main() raises:
var x = List[Float64]()
var y = List[Float64]()
for i in range(40):
var t = Float64(i) * 0.25
x.append(t)
y.append(sin(t) * 10.0 + t * 0.5)
var c = line(
x,
y,
theme=Theme(
mark_color=BROWN,
line_width=3.0,
show_gridlines=False,
),
)
save(c, "docs/src/examples/out_line.svg")Slope Chart
from dataviz_mojo import line
from dataviz_mojo.plot import save
from dataviz_mojo.theme import Theme
from dataviz_mojo.colors import SEAGREEN
def main() raises:
# x=0.0 ("2023"), x=1.0 ("2024") -- revenue, in millions.
var x: List[Float64] = [0.0, 1.0]
var revenue: List[Float64] = [42.0, 61.0]
var c = line(
x,
revenue,
theme=Theme(
mark_color=SEAGREEN,
line_width=3.0,
show_gridlines=False,
),
width=320,
height=420,
)
save(c, "docs/src/examples/out_slope.svg")Args:
x: The continuous x column, one entry per point.y: The continuous y column, one entry per point.theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – seeTheme’s docstring.width: Pixel width of the returnedPlot(.size()).height: Pixel height of the returnedPlot(.size()).title: The chart’s title, shown above the plot.x_title: The x-axis caption.y_title: The y-axis caption.