matplotlib_multicolored_line package

matplotlib_multicolored_line.colored_line(*args: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], c: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes], start: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = 0.5, end: Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | bool | int | float | complex | str | bytes | _NestedSequence[bool | int | float | complex | str | bytes] = 0, ax: Axes | None = None, **kwargs: Any) LineCollection[source]

Plot a line with a color specified along the line by a third value.

It does this by creating a collection of line segments. Each line segment is made up of two straight lines each connecting the current (x, y) point to the midpoints of the lines connecting the current point with its two neighbors. This creates a smooth line with no gaps between the line segments.

Parameters:
  • *args (array-like) – The horizontal and vertical coordinates of the data points of shape (N,) or (N, m).

  • c (array-like or array-like of color, optional) –

    The line values. Possible values: - array-like of numbers of shape (N,) or (N, m) to be mapped

    to colors using cmap and norm.

    • array-like of numbers of shape (N, m, 3) or (N, m, 4),

      where the last dimension is RGB or RGBA.

    • array-like of colors of shape (N,) or (N, m).

  • ax (matplotlib.axes.Axes, optional) – The axes to plot on. If not provided, the current axes will be used.

  • start (array-like, optional) – The ratio of the point where the color starts. Should be between 0 and 1.

  • end (array-like, optional) – The ratio of the point where the color changes. Should be between 0 and 1.

  • **kwargs (Any) – Any additional arguments to pass to matplotlib.collections.LineCollection constructor. This should not include the array keyword argument because that is set to the color argument. If provided, it will be overridden.

Returns:

The generated line collection representing the colored line.

Return type:

matplotlib.collections.LineCollection