Python 에서 seaborn 라 이브 러 리 의 countplot 데이터 시각 화 사용

Python 데이터 시각 화 에서 seaborn 은 도형 의 시각 화 효 과 를 잘 제공 합 니 다.
seaborn 공식 문서 참조 링크:http://seaborn.pydata.org/api.html
countplot 는 seaborn 라 이브 러 리 의 분류 도 중 하나 로 각 상자 의 관찰 계 수 를 선형 으로 표시 하 는 역할 을 합 니 다.다음은 seaborn 의 countplot 방법 에 대해 상세 하 게 설명 하 겠 습 니 다.갓 입문 한 동행 에 도움 이 되 기 를 바 랍 니 다.
seaborn 라 이브 러 리 가 져 오기

import seaborn as sns
countplot 사용 하기

sns.countplot()
countplot 방법 에 서 는 x 또는 y 인자 가 필요 합 니 다.그렇지 않 으 면 잘못 보고 합 니 다.
공식 적 으로 제 시 된 countplot 방법 및 매개 변수:
sns.countplot(x=None, y=None, hue=None, data=None, order=None, hue_order=None, orient=None, color=None, palette=None, saturation=0.75, dodge=True, ax=None, **kwargs)
다음은 countplot 방법의 매개 변 수 를 설명 합 니 다.타이 타 닉 호 를 예 로 들 면
원본 데 이 터 는 다음 과 같 습 니 다.

sns.set(style='darkgrid')
titanic = sns.load_dataset('titanic')
titanic.head()

x, y, hue : names of variables in ``data`` or vector data, optional. Inputs for plotting long-form data. See examples for interpretation.
첫 번 째 방식
x:x 축 에 있 는 막대 그래프 는 x 라벨 로 개 수 를 나눈다.
y:y 축 에 있 는 막대 그래프 는 y 태그 로 개 수 를 나 눕 니 다.
hue:x 또는 y 태그 로 구분 하 는 동시에 hue 태그 로 개 수 를 나 눕 니 다.

sns.countplot(x="class", data=titanic)

sns.countplot(y="class", data=titanic)

sns.countplot(x="class", hue="who", data=titanic)

두 번 째 방법
x:x 축 에 있 는 막대 그래프 는 series 데이터 입 니 다.
y:y 축 에 있 는 막대 그래프 는 series 데이터 입 니 다.

sns.countplot(x=titanic['class'])

sns.countplot(y=titanic['class'])

data : DataFrame, array, or list of arrays, optional. Dataset for plotting.
If ``x`` and ``y`` are absent, this is interpreted as wide-form. Otherwise it is expected to be long-form.
data:DataFrame 또는 array 또는 array 목록,그림 을 그 리 는 데이터 세트,x 또는 y 가 부족 할 때 data 매개 변 수 는 데이터 세트 이 고 x 또는 y 가 없어 서 는 안 되 며 그 중 하나 가 있어 야 합 니 다.

sns.countplot(x='class', data=titanic)

order, hue_order : lists of strings, optional.Order to plot the categorical levels in, otherwise the levels are inferred from the data objects.
order, hue_order 는 각각 x 또는 y 의 필드 정렬,hue 의 필드 정렬 입 니 다.정렬 방식 은 목록 입 니 다.

sns.countplot(x='class', data=titanic, order=['Third', 'Second', 'First'])

sns.countplot(x='class', hue='who', data=titanic, hue_order=['woman', 'man', 'child'])

orient : "v" | "h", optional
Orientation of the plot (vertical or horizontal). This is usually
inferred from the dtype of the input variables, but can be used to
specify when the "categorical" variable is a numeric or when plotting
wide-form data.
강제 방향,v:수직 방향;h:수평 방향,구체 적 인 실례 는 알 수 없다.
color : matplotlib color, optional
Color for all of the elements, or seed for a gradient palette.
palette : palette name, list, or dict, optional.Colors to use for the different levels of the ``hue`` variable.
Should be something that can be interpreted by :func:`color_palette`, or a dictionary mapping hue levels to matplotlib colors.
팔레트:다른 팔레트 사용 하기

sns.countplot(x="who", data=titanic, palette="Set3")

ax : matplotlib Axes, optional
Axes object to draw the plot onto, otherwise uses the current Axes.
좌표 계 를 지정 하 는 데 사용 합 니 다.

fig, ax = plt.subplots(1, 2, figsize=(10, 5))
sns.countplot(x='class', data=titanic, ax=ax[0])
sns.countplot(y='class', data=titanic, ax=ax[1])

파 이 썬 에서 seaborn 라 이브 러 리 의 countplot 데이터 시각 화 사용 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 관련 파 이 썬 seaborn 라 이브 러 리 countplot 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 많은 응원 부 탁 드 리 겠 습 니 다!

좋은 웹페이지 즐겨찾기