gsplot.plot.line_colormap_solid#

Functions

line_colormap_solid(ax,Β x,Β y,Β cmapdata[,Β ...])

Plots a solid line with a colormap applied along its segments.

line_colormap_solid(ax, x, y, cmapdata, cmap='viridis', linewidth=1, label=None, interpolation_points=None, **kwargs)[source]#

Plots a solid line with a colormap applied along its segments.

This function creates a solid line on the specified axis with colors mapped to the provided colormap data. It supports interpolation for smoother transitions between segments.

Parameters:
  • ax (matplotlib.axes.Axes) – The target axis for plotting.

  • x (ArrayLike) – The x-coordinates of the line.

  • y (ArrayLike) – The y-coordinates of the line.

  • cmapdata (ArrayLike) – Data values used to map colors to the line segments.

  • cmap (str, optional) – Name of the colormap to use (default is β€œviridis”).

  • linewidth (float or int, optional) – Width of the line (default is 1).

  • label (str or None, optional) – Label for the line, used in legends (default is None).

  • interpolation_points (int or None, optional) – Number of interpolation points for smooth color transitions (default is None).

  • **kwargs (Any) – Additional keyword arguments passed to the LegendColormap class.

Notes

  • This function utilizes the ParamsGetter to retrieve bound parameters and the CreateClassParams class to handle the merging of default, configuration, and passed parameters.

  • Alias validation is performed using the AliasValidator class.

    • β€˜lw’ (linewidth)

Returns:

A list containing the single LineCollection object for the plotted solid line.

Return type:

list[matplotlib.collections.LineCollection]

Examples

>>> import gsplot as gs
>>> x = [0, 1, 2, 3, 4]
>>> y = [1, 3, 2, 5, 4]
>>> cmapdata = [0.1, 0.3, 0.6, 0.9, 1.0]
>>> lc_list = gs.line_colormap_solid(ax=ax, x=x, y=y, cmapdata=cmapdata, cmap="plasma")
>>> print(len(lc_list))
1