10 Kinds of Data Analysis Charts Commonly Used by Seaborn

Source: Internet
Author: User
Keywords seaborn seaborn tutorial seaborn python

Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics.


Built in sample dataset

Seaborn has built-in more than a dozen sample datasets, through the load_ The dataset function can be called.
It includes the classic datasets such as Titanic and iris.
#View dataset types
import seaborn as sns
sns.get_ dataset_ names()
import seaborn as sns
#Export iris data set
data =  sns.load_ dataset('iris')
data.head ()
1. Scatter plot
function sns.scatterplot
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
#Tips data set
tips =  sns.load_ dataset('tips')
ax =  sns.scatterplot (x='total_ bill',y='tip',data=tips)
plt.show ()
2. Bar chart
function sns.barplot
Display data mean and confidence interval
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
#Tip dataset
tips =  sns.load_ dataset("tips")
ax =  sns.barplot (x="day", y="total_ bill", data=tips)
plt.show ()
3. Line drawing
function sns.lineplot
Draw line chart and confidence interval
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
fmri =  sns.load_ dataset("fmri")
ax =  sns.lineplot (x="timepoint", y="signal", data=fmri)
plt.show ()
4. Box diagram
function seaborn.boxplot
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
tips =  sns.load_ dataset("tips")
ax =  sns.boxplot (x="day", y="total_ bill", data=tips)
plt.show ()
5. Histogram
function seaborn.distplot
import seaborn as sns
import numpy as np
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
np.random.seed (0)
x =  np.random.randn (1000)
ax =  sns.distplot (x)
plt.show ()
6. Thermograph
function seaborn.heatmap
import numpy as np
np.random.seed (0)
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
uniform_ data =  np.random.rand (10, 12)
ax =  sns.heatmap (uniform_ data)
plt.show ()
7. Scatter matrix
function sns.pairplot
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
iris =  sns.load_ dataset("iris")
ax =  sns.pairplot (iris)
plt.show ()
8. Classified scatter plot
function seaborn.catplot
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
exercise =  sns.load_ dataset("exercise")
ax =  sns.catplot (x="time", y="pulse", hue="kind", data=exercise)\
plt.show ()
9. Counting bar chart
function seaborn.countplot
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
titanic =  sns.load_ dataset("titanic")
ax =  sns.countplot (x="class", data=titanic)
plt.show ()
10. Regression graph
Function seaborn.lmplot
Drawing scatter and regression map
import seaborn as sns
sns.set ()
import  matplotlib.pyplot  as plt
%matplotlib inline
tips =  sns.load_ dataset("tips")
ax =  sns.lmplot (x="total_ bill", y="tip", data=tips)
plt.show ()
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.