0% found this document useful (0 votes)
22 views4 pages

Seaborn

Seaborn is a Python library designed for attractive statistical data visualization, built on matplotlib and integrated with Pandas. It offers various plot categories, including line plots, distribution plots, and linear regression plots, to explore relationships between variables. Installation can be done via pip, and examples are provided for creating different types of plots.

Uploaded by

poonamrmk4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views4 pages

Seaborn

Seaborn is a Python library designed for attractive statistical data visualization, built on matplotlib and integrated with Pandas. It offers various plot categories, including line plots, distribution plots, and linear regression plots, to explore relationships between variables. Installation can be done via pip, and examples are provided for creating different types of plots.

Uploaded by

poonamrmk4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Seaborn

Python seaborn Library


Seaborn is one of an amazing library for visualization of the graphical statistical
plotting in Python. Seaborn provides many color palettes and defaults beautiful
styles to make the creation of many statistical plots in Python more attractive.

Objective of Python Seaborn library


Seaborn library aims to make a more attractive visualization of the central part
of understanding and exploring data. It is built on the core of
the matplotlib library and also provides dataset-oriented APIs.

Seaborn is also closely integrated with the Panda's data structures, and with
this, we can easily jump between the various different visual representations for
a given variable to better understand the provided dataset.

Categories of Plots in Python's seaborn library


Plots are generally used to make visualization of the relationships between the
given variables. These variables can either be a category like a group, division,
or class or can be completely numerical variables. There are various different
categories of plots that we can create using the seaborn library.

Installation of seaborn library for Python


pip install seaborn

Plotting Chart Using seaborn Library

1. Line plot:

The seaborn line plot is one of the most basic plots presents in the seaborn
library. We use the seaborn line plot mainly to visualize the given data in some
time-series form, i.e., in a continuous manner with respect to time.

# Importing seaborn library in program

import seaborn as sns

# Importing mataplotlib library to show graph in output

import matplotlib.pyplot as plt


# Setting style with set() function

sns.set(style="dark")

# Using dataset() function to declare data type

FMR = sns.load_dataset("fmri")

# Plotting various responses for different\

# Regions and events

sns.lineplot(x="timepoint",

y="signal",

hue="region",

style="event",

data=FMR) # using lineplot() function to create line plot

plt.show() # using show() function

Output:

2. Dist plot:

We use the seaborn dist plots to plot histograms with the given variables and
data as a result. We can plot histograms with some other variations such as
rugplot and kdeplot using a dist plot.
Example -

# importing numpy as np library module


import numpy as np
# Importing seaborn library in program
import seaborn as sns
# Importing mataplotlib library to show graph in output
import matplotlib.pyplot as plt
# Selecting style for boxplot with set() function
sns.set(style="white")
# Generate a random univariate type distribution
ru = np.random.RandomState(10)
d = ru.normal(size=100)
# Plotting a simple histogram with kdeplot variation
sns.histplot(d, kde=True, color="m")
plot = sns.histplot(d, kde=True, color="m")
print(plot)
plt.show() # using show() function

3. Lmplot:
The Lmplot is another one of the basic plots in the seaborn library. The Lmplot
shows a line that represents a linear regression model with the data points on
the given two-dimensional (2-D) space. In this 2-D space, we can set x and y
variables as the vertical and horizontal labels, respectively.
Example:
# Importing seaborn library in program
import seaborn as sns
# Importing matplotlib library to show graph in output
import matplotlib.pyplot as plt
# Using set() function to set style
sns.set(style="ticks")
# Using dataset() function
ds = sns.load_dataset("anscombe")
# Showing results in the form of linear regression
sns.lmplot(x="x", y="y", data=ds)

plot = sns.lmplot(x="x", y="y", data=ds)


print(plot)
plt.show() # using show() function
Output:

You might also like