voyagerpy.plotting.plot_fitline#

voyagerpy.plotting.plot_fitline(x: str | Series | ndarray, y: str | Series | ndarray, alternative: str = 'two-sided', ax: Axes | None = None, color: str | None = None, data: Any | None = None, xlim: Tuple[float | None, float | None] | None = None, ylim: Tuple[float | None, float | None] | None = None) Axes#

Fit a linear model to the data and plot the fit line.

The line is fit through the points given by x and y with the alternative hypothesis given by alternative. The line is then plotted on the given axes, with limits given by xlim and ylim. If either x or y are strings, they are assumed to be column names in data. Before the line is fit, any NaN values are removed from the data without alterring the original data.

Parameters:
  • x (Union[str, Series, np.ndarray]) – The column name or data to use for the x-axis.

  • y (Union[str, Series, np.ndarray]) – The column name or data to use for the y-axis.

  • alternative (str, optional) – The alternative hypothesis to use in linregress(), by default “two-sided”

  • ax (Optional[Axes], optional) – The axes to plot on, by default None

  • color (Optional[str], optional) – The color of the line. Can be None or matplotlib-style color string, by default None

  • data (Any, optional) – Mappable, must have x and y as keys if they are strings, by default None

  • xlim (Optional[Tuple[Optional[float], Optional[float]]], optional) – The limit on the x-axis, by default None

  • ylim (Optional[Tuple[Optional[float], Optional[float]]], optional) – The limit on the y-axis, by default None

Returns:

The axes with the fit line added.

Return type:

Axes