gsplot.plot.line#
Functions
|
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
orNone
, 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
orfloat
, optional) β The size of the markers (default is 7.0).markeredgewidth (
int
orfloat
, optional) β The width of the marker edges (default is 1.5).markeredgecolor (
ColorType
orNone
, optional) β The edge color of the markers (default is None).markerfacecolor (
ColorType
orNone
, optional) β The face color of the markers (default is None).linestyle (
LineStyleType
, optional) β The style of the line (default is βββ).linewidth (
int
orfloat
, optional) β The width of the line (default is 1.0).alpha (
int
orfloat
, optional) β The transparency level of the line (default is 1).alpha_mfc (
int
orfloat
, optional) β The transparency level of the marker face color (default is 0.2).label (
str
orNone
, 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:
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...>]