gsplot.plot.line_colormap_dashed#
Functions
|
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
orfloat
, 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
orNone
, optional) β The label for the line, used in legends (default is None).xspan (
float
orNone
, optional) β The span of x-coordinates for scaling, calculated automatically if None (default is None).yspan (
float
orNone
, 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))