gsplot.plot.line_colormap_solid#
Functions
|
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
orint
, optional) β Width of the line (default is 1).label (
str
orNone
, optional) β Label for the line, used in legends (default is None).interpolation_points (
int
orNone
, 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