Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library and also closely integrated to the data structures from pandas.
Visual representation of a dataset must be chosen according to the dataset or the type of answer we want from the plot. Scatter plots are highly preferred for visualising statistical relationships. But when it comes to a data which is varying with time (or continuous variable), scatter plots are not a good choice. Instead, in Seaborn, lineplot() or relplot() with kind = ‘line’ must be preferred. Line plots give annotation to each of the points and plus helps in customizing markers, line style, and legends.
Syntax: seaborn.lineplot(x=None, y=None, hue=None, size=None, style=None, data=None, palette=None, hue_order=None, hue_norm=None, sizes=None, size_order=None, size_norm=None, dashes=True, markers=None, style_order=None, units=None, estimator=’mean’, ci=95, n_boot=1000, seed=None, sort=True, err_style=’band’, err_kws=None, legend=’brief’, ax=None, **kwargs)
x, y: Input data variables; must be numeric.
data: Dataframe where each column is a variable and each row is an observation.
size: Grouping variable that will produce lines with different widths.
style: Grouping variable that will produce lines with different dashes and/or markers.
Example 1: Let’s take an example of FMRI dataset. It is an example of time series data, where variables are a function of time. This dataset is in-built available and can be accessed using load_dataset() and needs not to be downloaded separately.
# import libraries import seaborn as sns # load dataset fmri = sns.load_dataset("fmri")