Skip to content

LineChart(x=None, y=None, colors=None, line=LineType.SOLID, marker=MarkerShape.NONE) Source

Bases: Chart

Chart drawing each series as a line joining its values, used by Plot.line.

A missing value breaks the line, which starts again at the next present value.

Added in version 0.1.0

Parameters:

  • x (str | None, default: None)

    For a Table, the column of the horizontal positions: numbers, dates, datetimes, times of day, texts or booleans, the row numbers when omitted. An Array takes none, its rows being numbered. Times of day are placed on an axis of one day labeled HH:MM.

  • y (list[str] | None, default: None)

    For a Table, the columns drawn, holding numbers or times of day, not both, one line each. A Table needs it, even for a single column. An Array takes none: when omitted, each of its columns is a line. Times of day are measured on an axis labeled HH:MM.

  • colors (Sequence[Color | CustomColor] | None, default: None)

    One color per line, the colors of the default cycle when omitted. The chart keeps its own list.

  • line (LineType, default: LineType.SOLID)

    How the lines are drawn, LineType.SOLID by default.

  • marker (MarkerShape, default: MarkerShape.NONE)

    The shape drawn at each value, MarkerShape.NONE by default.

Raises:

Examples:

import numdaplot as ndp

days = ndp.Array.from_list([1, 2, 3, 4])
prices = ndp.Array.from_list([12.0, 15.5, 14.0, 17.0])
costs = ndp.Array.from_list([8.0, 9.5, None, 10.0])
sales = ndp.Table.from_arrays({"day": days, "price": prices, "cost": costs})
colors = [ndp.Color.BLUE, ndp.CustomColor("#ff8800")]
chart = ndp.LineChart(x="day", y=["price", "cost"], colors=colors, marker=ndp.MarkerShape.CIRCLE)
plot = ndp.Plot.line(sales, chart)
plot.show()

Plot drawn by the example