Python 에서 seaborn 라 이브 러 리 의 countplot 데이터 시각 화 사용
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 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 많은 응원 부 탁 드 리 겠 습 니 다!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Python의 None과 NULL의 차이점 상세 정보그래서 대상 = 속성 + 방법 (사실 방법도 하나의 속성, 데이터 속성과 구별되는 호출 가능한 속성 같은 속성과 방법을 가진 대상을 클래스, 즉 Classl로 분류할 수 있다.클래스는 하나의 청사진과 같아서 하나의 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.