Show change over time or another ordered continuous variable.
Continuous progression
Seaborn · Function
seaborn.lineplot draws a line chart for an x–y relationship and can distinguish subsets with color, width, and style. It aggregates repeated observations by default and shows an estimate with uncertainty.
lineplot maps variables to line position and can distinguish subsets with color, width, and style. When multiple y observations share an x value, it aggregates them by default and displays a central estimate with an uncertainty interval.
seaborn.lineplot(data=None, *, x=None, y=None, hue=None, size=None, style=None, units=None, weights=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, dashes=True, markers=None, style_order=None, estimator='mean', errorbar=('ci', 95), n_boot=1000, seed=None, orient='x', sort=True, err_style='band', err_kws=None, legend='auto', ci='deprecated', ax=None, **kwargs)| Name | Type | Description |
|---|---|---|
data | pandas.DataFrame, numpy.ndarray, mapping, or sequence | Input data structure. |
x, y | vectors or keys in data | Variables that specify positions on the x and y axes. |
hue | vector or key in data | Grouping variable that will produce lines with different colors. |
size | vector or key in data | Grouping variable that will produce lines with different widths. |
style | vector or key in data | Grouping variable that will produce lines with different dashes and/or markers. |
units | vector or key in data | Grouping variable that will produce separate lines without affecting line appearance. |
estimator | name of pandas method, callable, or None | Method for aggregating over observations. |
errorbar | string, tuple, callable, or None | Method for calculating the uncertainty estimate. |
ax | matplotlib.axes.Axes | Axes object to draw the plot onto. |
Returns the Axes object with the plot drawn onto it.
import seaborn as sns
import matplotlib.pyplot as plt
sns.set_theme(style="whitegrid")
data = {"time": [1, 2, 3, 1, 2, 3], "value": [2, 4, 3, 1, 3, 5], "group": ["A", "A", "A", "B", "B", "B"]}
sns.lineplot(data=data, x="time", y="value", hue="group", marker="o")
plt.show()Plots the mean value at each time for two groups, using color and markers to distinguish them.
Continuous progression
Grouped trends
Uncertainty visualization
lineplot draws a relationship between x and y and supports semantic grouping through hue, size, and style. It can show separate subsets of the data while varying color, line width, or line pattern.
Follow-up: How can three additional variables be represented? Use hue, size, and style independently, while checking that the combined encodings remain interpretable.
With repeated y observations at an x value, the function aggregates them by default. It shows an estimate of central tendency together with a confidence interval.
Follow-up: What should you consider when interpreting the line? Determine whether the aggregation and uncertainty interval match the question, rather than treating the line as every raw observation.
The function accepts x and y variables plus an optional data structure, and hue can produce differently colored lines for groups. The current signature also exposes controls such as estimator, errorbar, sorting, and legend behavior.
Follow-up: How would you make group distinctions more explicit? Combine semantic mappings selectively, for example hue with style, and use ordering parameters when the displayed order matters.
seaborn.scatterplotseaborn.relplotseaborn.set_themeseaborn.load_dataset