Skip to content

Line

daspi.plotlib.plotter.Line(source, target, feature='', target_on_y=True, color=None, ax=None, visible_spines=None, hide_axis=None, **kwds)

Bases: Plotter

A line plotter that extends the Plotter base class.

PARAMETER DESCRIPTION
source

Pandas long format DataFrame containing the data source for the plot.

TYPE: pandas DataFrame

target

Column name of the target variable for the plot.

TYPE: str

feature

Column name of the feature variable for the plot, by default ''

TYPE: str DEFAULT: ''

target_on_y

Flag indicating whether the target variable is plotted on the y-axis, by default True

TYPE: bool DEFAULT: True

color

Color to be used to draw the artists. If None, the first color is taken from the color cycle, by default None.

TYPE: str | None DEFAULT: None

ax

The axes object for the plot. If None, the current axes is fetched using plt.gca(). If no axes are available, a new one is created. Defaults to None.

TYPE: Axes | None DEFAULT: None

visible_spines

Specifies which spines are visible, the others are hidden. If 'none', no spines are visible. If None, the spines are drawn according to the stylesheet. Defaults to None.

TYPE: Literal['target', 'feature', 'none'] | None DEFAULT: None

hide_axis

Specifies which axes should be hidden. If None, both axes are displayed. Defaults to None.

TYPE: Literal['target', 'feature', 'both'] | None DEFAULT: None

**kwds

Those arguments have no effect. Only serves to catch further arguments that have no use here (occurs when this class is used within chart objects).

DEFAULT: {}

Examples:

Apply to an existing Axes object:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from daspi import Line

fig, ax = plt.subplots()
df = pd.DataFrame({'x': list(x*np.pi/50 for x in range(100))})
df['y'] = np.cos(df['x'])
line = Line(source=df, target='y', feature='x', ax=ax)
line(color='red', lw=2, alpha=0.6)

Apply using the plot method of a DaSPi Chart object

import numpy as np
import daspi as dsp
import pandas as pd

df = pd.DataFrame({'x': list(x*np.pi/50 for x in range(100))})
df['y'] = np.cos(df['x'])

chart = dsp.SingleChart(
        source=df,
        target='y',
        feature='x'
    ).plot(
        dsp.Line,
        kw_call=dict(color='red', lw=2, alpha=0.6))

kw_default property

Default keyword arguments for plotting (read-only)