gsplot.plot.line_colormap_dashed#

Functions

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

A convenience function to plot dashed lines with a colormap applied to individual segments.

line_colormap_dashed(ax, x, y, cmapdata, cmap='viridis', linewidth=1, line_pattern=(10, 10), label=None, xspan=None, yspan=None, **kwargs)[source]#

A convenience function to plot dashed lines with a colormap applied to individual segments.

This function wraps the LineColormapDashed class for ease of use. It handles axis resolution, alias validation, and parameter merging automatically.

Parameters:
  • ax (matplotlib.axes.Axes) – The target axis where the line will be plotted.

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

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

  • cmapdata (ArrayLike) – The data used for coloring the line segments. Values will be normalized to map to colors.

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

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

  • line_pattern (tuple[float, float], optional) – A tuple specifying the lengths of solid and gap segments in the dash pattern (default is (10, 10)).

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

  • xspan (float or None, optional) – The span of x-coordinates for scaling, calculated automatically if None (default is None).

  • yspan (float or None, optional) – The span of y-coordinates for scaling, calculated automatically if None (default is None).

  • **kwargs (Any) – Additional keyword arguments passed to Matplotlib functions.

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 for linewidth

Returns:

A list of LineCollection objects representing the plotted dashed line.

Return type:

list[matplotlib.collections.LineCollection]

Examples

>>> import gsplot as gs
>>> x = [0, 1, 2, 3]
>>> y = [1, 2, 3, 4]
>>> cmapdata = [0.1, 0.4, 0.6, 0.9]
>>> line_collections = gs.line_colormap_dashed(ax, x, y, cmapdata, line_pattern=(5, 5))