[seaborn을 이용한 데이터 시각화] #01. rugplot, kdeplot, distplot, countplot

1차원 분포 플롯

1. 1차원 실수 분포 플롯

1) rugplot

  • height : Draw a taller rug
    sns.rugplot(data=tips, x="total_bill", y="tip", height=.1)​
  • hue : Represent a third variable with hue mapping
    sns.rugplot(data=tips, x="total_bill", y="tip", hue="time")​
  • clip_on=False : Put the rug outside the axes
    sns.rugplot(data=tips, x="total_bill", y="tip", height=-.02, clip_on=False)​
  • alpha : Show the density of a larger dataset using thinner lines and alpha blending
    sns.rugplot(data=diamonds, x="carat", y="price", lw=1, alpha=.005)

 

 

seaborn.rugplot — seaborn 0.11.1 documentation

Axis to draw the rug on. Deprecated since version 0.11.0: specify axis by assigning the x or y variables.

seaborn.pydata.org


2) kdeplot

  • bw_adjust=.2 : Use less smoothing
sns.kdeplot(data=tips, x="total_bill", bw_adjust=.2)
  • cut=0 : Use more smoothing, but don’t smooth past the extreme data points
ax= sns.kdeplot(data=tips, x="total_bill", bw_adjust=5, cut=0)
  • multiple="stack" : “Stack” the conditional distributions
sns.kdeplot(data=tips, x="total_bill", hue="time", multiple="stack")
  • multiple="fill" : Normalize the stacked distribution at each value in the grid
    sns.kdeplot(data=tips, x="total_bill", hue="time", multiple="fill")
  • fill=True, common_norm=False, palette="crest" : Modify the appearance of the plot
    sns.kdeplot(
       data=tips, x="total_bill", hue="size",
       fill=True, common_norm=False, palette="crest",
       alpha=.5, linewidth=0,
    )
 

seaborn.kdeplot — seaborn 0.11.1 documentation

Orientation parameter. Deprecated since version 0.11.0: specify orientation by assigning the x or y variables.

seaborn.pydata.org


3) distplot

  • vertical=True : Plot the distribution on the vertical axis
ax = sns.distplot(x, vertical=True)
  • color="y" : Change the color of all the plot elements
sns.set_color_codes()
ax = sns.distplot(x, color="y")

 

 

seaborn.distplot — seaborn 0.11.1 documentation

DEPRECATED: Flexibly plot a univariate distribution of observations. Warning This function is deprecated and will be removed in a future version. Please adapt your code to use one of two new functions: displot(), a figure-level function with a similar flex

seaborn.pydata.org


2. 카운트 플롯

1) countplot

  • palette="Set3" : Use a different color palette
ax = sns.countplot(x="who", data=titanic, palette="Set3")
ax = sns.countplot(x="who", data=titanic,
                   facecolor=(0, 0, 0, 0),
                   linewidth=5,
                   edgecolor=sns.color_palette("dark", 3))
g = sns.catplot(x="class", hue="who", col="survived",
                data=titanic, kind="count",
                height=4, aspect=.7);

 

seaborn.countplot — seaborn 0.11.1 documentation

Vectors of data represented as lists, numpy arrays, or pandas Series objects passed directly to the x, y, and/or hue parameters.

seaborn.pydata.org


cf. 

 

[Python] seaborn 데이터 시각화 총정리 - GROWTH.J

seaborn은 matplotlib 처럼 그래프를 그리는 기능이다(matplotlib으로 그래프 그리는 꿀팁이 궁금하다면?). matplotlip으로도 대부분의 시각화는 가능하지만 아래와 같은 이유들로 seaborn을 더 선호하는 추

growthj.link

 

 

Seaborn을 사용한 데이터 분포 시각화 — 데이터 사이언스 스쿨

.ipynb .pdf to have style consistency -->

datascienceschool.net