seaborn: Python's data visualization library. High level API. Beautiful.
Use seaborn
if it is prepared by seaborn
. If not, draw with matplotlib
.
Even if you draw with matplotlib
, it is better to use seaborn
for the style (it is set just by importing)
I often use default or "white" for style. Adjust font_scale by looking at the figure.
import seaborn as sns
sns.set(style="white", font_scale=1.3, palette="muted", color_codes=True)
View the gallery page of the official doc. (Since the functions that can be used are limited to the following, if you can imagine what you can do with the function name, you do not have to look at the link. You can check the details of the arguments with the help function of ipython.)
Visualization of distribution
function
argument --kde: Kernel density estimation --hist: Histogram --Hue: Distribution estimation by condition
Regression
function
argument --order: Polynomial regression --logistic: Logistic regression --hue: Conditional regression (col, row)
Categorical data
function
Read the dataset provided by seaborn
#dataset list: https://github.com/mwaskom/seaborn-data
sns.load_dataset('titanic')
Shaft removal
sns.despine() #Top and right
sns.despine(left=True) #Left too
color palettes
#Current color map
cmap_current = sns.color_palette()
sns.palplot(cmap_current)
#New color map
#reference: http://seaborn.pydata.org/tutorial/color_palettes.html
#Example: key = "set1" (categorical), "Blues" (sequential)
num = 8
cmap = sns.color_palette(key, num)
sns.palplot(cmap)
Recommended Posts