brief introduction
Seaborn is actually a higher-level API encapsulation based on Matplotlib, which makes drawing easier. In most cases, using Seaborn can make very attractive drawings, while using Matplotlib can make drawings with more characteristics.
Seaborn should be seen as a supplement to Matplotlib, not a substitute.
homepage
http://seaborn.pydata.org/
Visual chart details
2.1 line box drawing
The concept of statistical quartile is needed in the line box diagram. The so-called quartile is to arrange all the data in the group from small to large and divide them into quartiles. The number at three dividing points is the quartile.
import seaborn as sns
sns.set_ style("whitegrid")
tips = sns.load_ dataset("tips")
#Draw line box diagram
ax = sns.boxplot (x=tips["total_ bill"])
2.2 scatter diagram
There are two scatter graphs in
Seaborn, one is a general scatter graph, the other is a scatter graph that can see the distribution density. Now I can see by spending them together.
#Ordinary scatter diagram
ax1 = sns.stripplot (x=tips["total_ bill"])
#Scatter with distribution density
ax2 = sns.swarmplot (x=tips["total_ bill"])
2.3 violin chart
The violin diagram is actually a combination of box line diagram and core density diagram. The box line diagram shows the quantile position, while the violin diagram shows the density of any position. Through the violin diagram, you can know which position has higher density. In the figure, the white dot is the median, the black box type ranges from the lower quartile to the upper quartile, and the thin black line represents the whisker. The external shape is the kernel density estimation (in probability theory, it is used to estimate the unknown density function, which belongs to one of the nonparametric test methods).
ax = sns.violinplot (x=tips["total_ bill"])
2.4 histogram
Histogram hist = true, kernel density curve rug = true
#Drawing the density distribution of numerical variables
#By default, both kernel density curve and histogram are drawn
import seaborn as sns
import numpy as np
sns.set (rc={" figure.figsize ":(8,4)})
np.random.seed (0)
x = np.random.randn (100)
ax = sns.distplot (x)
2.5 regression chart
ax = sns.regplot (x="total_ bill",y="tip",data=tips)
2.6 heat map
import seaborn as sns
import numpy as np
np.random.seed (0)
sns.set ()
uniform_ data = np.random.rand (10,12)
ax = sns.heatmap (uniform_ data)
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.