gsplot.plot.line#

Functions

line(ax,Β x,Β y[,Β color,Β marker,Β markersize,Β ...])

A convenience function to plot a line with extensive customization on a Matplotlib axis.

line(ax, x, y, color=None, marker='o', markersize=7.0, markeredgewidth=1.5, markeredgecolor=None, markerfacecolor=None, linestyle='--', linewidth=1.0, alpha=1, alpha_mfc=0.2, label=None, *args, **kwargs)[source]#

A convenience function to plot a line with extensive customization on a Matplotlib axis.

This function wraps the Line class for easier usage and provides support for aliasing common parameters. It handles axis resolution, automatic color cycling, and parameter validation.

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

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

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

  • color (ColorType or None, optional) – The color of the line (default is None, using auto color cycling).

  • marker (MarkerType, optional) – The marker style for the data points (default is β€œo”).

  • markersize (int or float, optional) – The size of the markers (default is 7.0).

  • markeredgewidth (int or float, optional) – The width of the marker edges (default is 1.5).

  • markeredgecolor (ColorType or None, optional) – The edge color of the markers (default is None).

  • markerfacecolor (ColorType or None, optional) – The face color of the markers (default is None).

  • linestyle (LineStyleType, optional) – The style of the line (default is β€œβ€“β€œ).

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

  • alpha (int or float, optional) – The transparency level of the line (default is 1).

  • alpha_mfc (int or float, optional) – The transparency level of the marker face color (default is 0.2).

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

  • *args (Any) – Additional positional arguments passed to matplotlib.axes.Axes.plot.

  • **kwargs (Any) – Additional keyword arguments passed to matplotlib.axes.Axes.plot.

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.

    • β€˜ms’ (markersize)

    • β€˜mew’ (markeredgewidth)

    • β€˜ls’ (linestyle)

    • β€˜lw’ (linewidth)

    • β€˜c’ (color)

    • β€˜mec’ (markeredgecolor)

    • β€˜mfc’ (markerfacecolor).

Returns:

The list of Line2D objects representing the plotted line.

Return type:

list of matplotlib.lines.Line2D

Examples

>>> import gsplot as gs
>>> x = [0, 1, 2, 3]
>>> y = [1, 2, 3, 4]
>>> line_plot = gs.line(ax, x, y, color="blue", linestyle="-")
>>> print(line_plot)
[<matplotlib.lines.Line2D object at 0x...>]