Movatterモバイル変換


[0]ホーム

URL:


Open In App

Seaborn is a Python data visualization library based onmatplotlib. It provides a high-level interface for drawing attractive and informative statistical graphics. The colors stand out, the layers blend nicely together, the contours flow throughout, and the overall package not only has a nice aesthetic quality, but it provides meaningful insights to us as well.

seaborn.lineplot()

Draw a line plot with the possibility of several semantic groupings. The relationship between x and y can be shown for different subsets of the data using the hue, size, and style parameters. These parameters control what visual semantics are used to identify the different subsets. It is possible to show up to three dimensions independently by using all three semantic types, but this style of plot can be hard to interpret and is often ineffective. Using redundant semantics (i.e. both hue and style for the same variable) can be helpful for making graphics more accessible.

Syntax :sns.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, sort=True, err_style='band', err_kws=None, legend='brief', ax=None, **kwargs,)

Parameters:

x, y:Input data variables; must be numeric. Can pass data directly or reference columns in data.

hue:Grouping variable that will produce lines with different colors. Can be either categorical or numeric, although color mapping will behave differently in latter case.

style:Grouping variable that will produce lines with different dashes and/or markers. Can have a numeric dtype but will always be treated as categorical.

data:Tidy ("long-form") dataframe where each column is a variable and each row is an observation. 

markers:Object determining how to draw the markers for different levels of the style variable.

legend:How to draw the legend. If "brief", numeric ``hue`` and ``size`` variables will be represented with a sample of evenly spaced values.

Below is the implementation of above method with some examples :

Example 1:

Python3
# importing packagesimportseabornassnsimportmatplotlib.pyplotasplt# loading datasetdata=sns.load_dataset("iris")# draw lineplotsns.lineplot(x="sepal_length",y="sepal_width",data=data)plt.show()

Output :

Example 2 :

Python3
# importing packagesimportseabornassnsimportmatplotlib.pyplotasplt# loading datasetdata=sns.load_dataset("tips")# draw lineplot# hue by sex# style to huesns.lineplot(x="total_bill",y="size",hue="sex",style="sex",data=data)plt.show()

Output :


Improve
Improve
Article Tags :

Explore

Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences

[8]ページ先頭

©2009-2025 Movatter.jp