Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- trouble shooting
- 취업부트캠프
- 태블로
- 프리온보딩
- SQL
- 파이썬
- 러닝스푼즈
- 2024년
- 부트캠프후기
- 유데미부트캠프
- 스타터스부트캠프
- 자격증준비
- 데이터분석가
- 유데미
- Python
- 데이터시각화
- 실습
- tableau
- AICE
- 회고록
- 코테
- 프로그래머스
- 유데미코리아
- 프로젝트
- Tableau Desktop Specialist
- MySQL
- 쿼리테스트
- 자격증
- 데이터분석
- 코딩테스트
Archives
- Today
- Total
신이 되고 싶은 갓지이
[python 실습] seaborn 여러가지 시각화 본문
그래프에 수직선, 수평선 그리기¶
In [41]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
In [5]:
# 그래프에 한글폰트 설정
plt.rcParams['font.family'] = 'AppleGothic'
# 유니코드에서 그래프에 마이너스 기호 깨지는 문제 해결
plt.rcParams['axes.unicode_minus'] = False
In [6]:
# 그리드 스타일
plt.rcParams['grid.linestyle'] = '--'
plt.rcParams['grid.alpha'] = 0.3
수평선 그리기¶
plt.axhline(y좌표, x축시작위치, x축끝위치)
수평선의 길이가 1이라고 했을 때 x축시작위치, x축끝위치를 지정한다.
따로 지정하지 않으면 x축 전범위에 걸쳐 그려진다.plt.hlines(y, x축시작좌표, x축끝좌표)
In [103]:
plt.plot([1,2,3,4], 'ko')
plt.axhline(2,0,1, color='b', alpha=0.5, ls=':')
plt.hlines(3, 0.0, 3.0, color='darkorange', ls='-.')
plt.show()
수직선 그리기¶
axvline(x좌표, y축시작위치, y축끝위치)
수직선의 길이가 1이라고 했을 때 y축시작위치, y축끝위치를 지정한다.
따로 지정하지 않으면 y축 전범위에 걸쳐 그려진다.vlines(x, y축시작좌표, y축끝좌표)
In [104]:
plt.plot([1,2,3,4], 'ko')
plt.axvline(1, 0, 0.5, ls='--', color='r')
plt.vlines(2, 1.0, 3.0, ls=':', color='g')
plt.show()
예제 : 요일별 판매 테이블 수¶
In [10]:
import seaborn as sns
tips = sns.load_dataset('tips')
tips.head(3)
Out[10]:
| total_bill | tip | sex | smoker | day | time | size | |
|---|---|---|---|---|---|---|---|
| 0 | 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
| 1 | 10.34 | 1.66 | Male | No | Sun | Dinner | 3 |
| 2 | 21.01 | 3.50 | Male | No | Sun | Dinner | 3 |
요일 별 테이블 수¶
- 요일별 데이터 수
In [11]:
s = tips['day'].value_counts()
s
Out[11]:
Sat 87
Sun 76
Thur 62
Fri 19
Name: day, dtype: int64
In [12]:
plt.figure(figsize=(15,3)) # 가로사이즈 늘리기
plt.barh(s.index, s.values)
plt.xticks(range(0,91,1), rotation=90) # 레이블 90도로 회전
plt.grid(axis='x') # 그리드 표시
plt.axvline(s['Fri'], color='k')
plt.axvline(s['Thur'], color='k')
plt.axvline(s['Sun'], color='k')
plt.axvline(s['Sat'], color='k')
plt.show()
그래프에 설명적기¶
텍스트 추가하기¶
- plt.text(x좌표, y좌표, 텍스트)
- rotation=회전각도
- ha : horizontal alignment
- va : vertical alignment
- 텍스트 상자
bbox = {'boxstyle':상자스타일, 'fc':facecolor,'ec':edgecolor,...}
boxstyle : 'round'/'square'
In [107]:
plt.plot([1,2,3,4], 'ko')
plt.text(2.1, 3, '(x:2, y:3)', ha='left', va='bottom', fontsize=12, rotation=45
, bbox={'boxstyle':'round', 'fc':'skyblue', 'ec':'b', 'alpha':0.3})
plt.axhline(3, ls=':', alpha=0.5, lw=0.5)
plt.axvline(2, ls=':', alpha=0.5, lw=0.5)
plt.plot(2,3,'ro')
plt.show()
화살표와 텍스트 추가하기¶
plt.annotate('텍스트',xy=(화살표x,화살표y), xytext=(텍스트x,텍스트y), arrowprops=화살표속성(딕셔너리))
화살표 속성 width The width of the arrow in points headwidth The width of the base of the arrow head in points headlength The length of the arrow head in points shrink Fraction of total length to shrink from both ends
In [109]:
plt.plot([1,2,3,4], 'ko')
plt.axhline(2, color='orange', lw=0.5, alpha=0.5, ls='--')
plt.axvline(1, color='orange', lw=0.5, alpha=0.5, ls='--')
plt.plot(1,2,'ro')
plt.annotate('(x:1,y:2)', xy=(1,2), xytext=(1.5,2.5)
, arrowprops={'width':1, 'headwidth':10, 'headlength':10, 'shrink':0.1, 'fc':'r'}
, fontsize=12, color='r')
plt.show()
2중y축 표시하기¶
In [25]:
age = [13,14,15,16,17]
height = [160,165,170,173,177]
weight = [80,85,83,78,73]
두가지 정보를 하나의 그래프에 그리기¶
- 축을 분리하기 위해 객체지향으로 그린다.
- fig, ax = plt.subplots()
In [26]:
fig, ax = plt.subplots()
ax.bar(age, height, color='skyblue', width=0.5, ec='lightgray', label='height')
ax.plot(age, weight, color='darkred', marker='o', ls='-.', label='weight')
plt.legend()
plt.show()
2중 y축 만들기¶
- x축을 공유하는 새로운 axes객체를 만든다.
axes객체.twinx()
In [27]:
fig, ax1 = plt.subplots()
ax1.bar(age, height, color='skyblue', width=0.5, ec='lightgray', label='height')
ax2 = ax1.twinx()
ax2.plot(age, weight, color='darkred', marker='o', ls='-.', label='weight')
plt.show()
축 레이블 표시하기¶
axes객체.set_xlabel(x레이블)axes객체.set_ylabel(y레이블)
In [31]:
fig, ax1 = plt.subplots()
ax1.bar(age, height, color='skyblue', width=0.5, ec='lightgray', label='height')
ax2 = ax1.twinx()
ax2.plot(age, weight, color='darkred', marker='o', ls='-.', label='weight')
ax1.set_xlabel('나이')
ax1.set_ylabel('키(cm)')
ax2.set_ylabel('몸무게(kg)')
plt.show()
y축 범위 지정¶
- axes객체.set_ylim(y축눈금범위)
In [32]:
fig, ax1 = plt.subplots()
ax1.bar(age, height, color='skyblue', width=0.5, ec='lightgray', label='height')
ax2 = ax1.twinx()
ax2.plot(age, weight, color='darkred', marker='o', ls='-.', label='weight')
ax1.set_xlabel('나이')
ax1.set_ylabel('키(cm)')
ax2.set_ylabel('몸무게(kg)')
ax1.set_ylim(150,180)
ax2.set_ylim(60,90)
plt.show()
y축 눈금¶
- axes객체.set_yticks(y축눈금)
- axes객체.tick_params(...)
In [33]:
fig, ax1 = plt.subplots()
ax1.bar(age, height, color='skyblue', width=0.5, ec='lightgray', label='height')
ax2 = ax1.twinx()
ax2.plot(age, weight, color='darkred', marker='o', ls='-.', label='weight')
ax1.set_xlabel('나이')
ax1.set_ylabel('키(cm)')
ax2.set_ylabel('몸무게(kg)')
ax1.set_ylim(150,180)
ax2.set_ylim(60,90)
ax1.set_yticks(height)
ax2.set_yticks(weight)
ax1.tick_params(axis='y', colors='skyblue')
ax2.tick_params(axis='y', colors='darkred')
plt.show()
범례 표시¶
- axes객체별로 legend메소드 호출
In [34]:
fig, ax1 = plt.subplots()
ax1.bar(age, height, color='skyblue', width=0.5, ec='lightgray', label='height')
ax2 = ax1.twinx()
ax2.plot(age, weight, color='darkred', marker='o', ls='-.', label='weight')
ax1.set_xlabel('나이')
ax1.set_ylabel('키(cm)')
ax2.set_ylabel('몸무게(kg)')
ax1.set_ylim(150,180)
ax2.set_ylim(60,90)
ax1.set_yticks(height)
ax2.set_yticks(weight)
ax1.tick_params(axis='y', colors='skyblue')
ax2.tick_params(axis='y', colors='darkred')
ax1.legend()
ax2.legend()
plt.show()
그리드 표시¶
- axes객체.grid()
In [110]:
fig, ax1 = plt.subplots()
ax1.bar(age, height, color='skyblue', width=0.5, ec='lightgray', label='height')
ax2 = ax1.twinx()
ax2.plot(age, weight, color='darkred', marker='o', ls='-.', label='weight')
ax1.set_xlabel('나이')
ax1.set_ylabel('키(cm)')
ax2.set_ylabel('몸무게(kg)')
ax1.set_ylim(150,180)
ax2.set_ylim(60,90)
ax1.set_yticks(height)
ax2.set_yticks(weight)
ax1.tick_params(axis='y', colors='skyblue')
ax2.tick_params(axis='y', colors='darkred')
ax1.legend()
ax2.legend()
ax1.grid(axis='y', ls='--', color='skyblue')
ax2.grid(axis='y', ls='--', color='pink')
plt.show()
seaborn-막대그래프¶
In [38]:
tips = sns.load_dataset('tips')
In [39]:
tips.head()
Out[39]:
| total_bill | tip | sex | smoker | day | time | size | |
|---|---|---|---|---|---|---|---|
| 0 | 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
| 1 | 10.34 | 1.66 | Male | No | Sun | Dinner | 3 |
| 2 | 21.01 | 3.50 | Male | No | Sun | Dinner | 3 |
| 3 | 23.68 | 3.31 | Male | No | Sun | Dinner | 2 |
| 4 | 24.59 | 3.61 | Female | No | Sun | Dinner | 4 |
In [40]:
tips.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 244 entries, 0 to 243
Data columns (total 7 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 total_bill 244 non-null float64
1 tip 244 non-null float64
2 sex 244 non-null category
3 smoker 244 non-null category
4 day 244 non-null category
5 time 244 non-null category
6 size 244 non-null int64
dtypes: category(4), float64(2), int64(1)
memory usage: 7.4 KB
요일별 팁 평균¶
matplotlib으로 시각화¶
데이터 가공¶
- 요일별 팁 평균 계산
- 그룹핑 : 데이터프레임.groupby(그룹기준컬럼)[통계적용컬럼].통계함수
In [42]:
day_tip_mean = tips.groupby('day')['tip'].mean()
day_tip_mean
Out[42]:
day
Thur 2.771452
Fri 2.734737
Sat 2.993103
Sun 3.255132
Name: tip, dtype: float64
데이터 시각화¶
- plt.bar(x,y)
In [44]:
plt.bar(day_tip_mean.index, day_tip_mean)
plt.xlabel('day')
plt.ylabel('tip')
plt.title('요일별 팁 평균', size=15)
plt.show()
seaborn으로 그리기¶
- `sns.barplot(data=데이터프레임명, x=x축컬럼, y=y축컬럼)`
- x축데이터로 그룹핑한 y축데이터의 평균값을 계산하여 그래프를 그려준다.
- 신뢰구간(CI:Confidence Interval)을 함께 표시
In [46]:
sns.barplot(data=tips, x='day', y='tip', errorbar=None)
plt.title('요일별 팁 평균', size=15)
plt.show()
요일별 팁 합계¶
matplotlib으로 그리기¶
In [47]:
day_tip_sum = tips.groupby('day')['tip'].sum()
day_tip_sum
Out[47]:
day
Thur 171.83
Fri 51.96
Sat 260.40
Sun 247.39
Name: tip, dtype: float64
In [48]:
plt.bar(day_tip_sum.index, day_tip_sum)
plt.xlabel('day')
plt.ylabel('tip')
plt.title('요일별 팁 합계', size=15)
plt.show()
seaborn으로 그리기¶
- estimator = 통계함수
In [52]:
sns.barplot(data=tips, x='day', y='tip', errorbar=('ci',90), estimator=sum)
plt.title('요일별 팁 합계', size=15)
plt.show()
요일별 팁 합계를 흡연여부로 비교¶
- hue : y를 그룹핑할 컬럼
In [53]:
sns.barplot(data=tips, x='day', y='tip', errorbar=None, estimator=sum, hue='smoker')
plt.title('요일별 팁 합계', size=15)
plt.show()
- hue 색상 변경 : palette = 구분:색상 딕셔너리
In [54]:
sns.barplot(data=tips, x='day', y='tip', errorbar=None, estimator=sum, hue='smoker'
, palette ={'Yes':'gray', 'No':'skyblue'})
plt.title('요일별 팁 합계', size=15)
plt.show()
- pyplot의 메소드로 그리드 추가
In [56]:
sns.barplot(data=tips, x='day', y='tip', errorbar=None, estimator=sum, hue='smoker'
, palette ={'Yes':'gray', 'No':'skyblue'})
plt.title('요일별 팁 합계', size=15)
plt.grid(axis='y', ls=':')
plt.show()
데이터의 관계파악을 위한 scatterplot¶
In [58]:
tips = sns.load_dataset('tips')
In [59]:
tips.head()
Out[59]:
| total_bill | tip | sex | smoker | day | time | size | |
|---|---|---|---|---|---|---|---|
| 0 | 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
| 1 | 10.34 | 1.66 | Male | No | Sun | Dinner | 3 |
| 2 | 21.01 | 3.50 | Male | No | Sun | Dinner | 3 |
| 3 | 23.68 | 3.31 | Male | No | Sun | Dinner | 2 |
| 4 | 24.59 | 3.61 | Female | No | Sun | Dinner | 4 |
total_bill과 tip의 관계¶
matplotlib으로 그리기¶
plt.scatter(x,y)
In [60]:
plt.scatter(tips['total_bill'],tips['tip'])
plt.show()
요일 구분¶
- total_bill에 따른 tip의 분포 - 색상으로 요일 표시
'Sun':'red'
'Sat':'blue'
'Thur':'green'
'Fri':'yello'
In [61]:
tips['day'].unique()
Out[61]:
['Sun', 'Sat', 'Thur', 'Fri']
Categories (4, object): ['Thur', 'Fri', 'Sat', 'Sun']
요일별 서브셋 만들기¶
In [62]:
tips_Sun = tips[tips['day']=='Sun']
In [63]:
tips_Sat = tips[tips['day']=='Sat']
In [64]:
tips_Fri = tips[tips['day']=='Fri']
In [65]:
tips_Thur = tips[tips['day']=='Thur']
시각화하기¶
In [66]:
plt.scatter(tips_Sun['total_bill'], tips_Sun['tip'], label='Sun', s=tips_Sun['size']*30, alpha=0.5)
plt.scatter(tips_Sat['total_bill'], tips_Sat['tip'], label='Sat', s=tips_Sat['size']*30, alpha=0.5)
plt.scatter(tips_Fri['total_bill'], tips_Fri['tip'], label='Fri', s=tips_Fri['size']*30, alpha=0.5)
plt.scatter(tips_Thur['total_bill'], tips_Thur['tip'], label='Thur', s=tips_Thur['size']*30, alpha=0.5)
plt.legend()
plt.xlabel('total_bill')
plt.ylabel('tip')
plt.show()
seaborn으로 그리기¶
- `sns.scatterplot(data=데이터프레임, x=x축컬럼, y=y축컬럼)`
In [111]:
sns.scatterplot(data=tips, x='total_bill', y='tip', hue='day', size='size', alpha=0.5)
plt.show()
데이터의 추세를 표현하는 lineplot¶
In [70]:
flights = sns.load_dataset('flights')
flights.head()
Out[70]:
| year | month | passengers | |
|---|---|---|---|
| 0 | 1949 | Jan | 112 |
| 1 | 1949 | Feb | 118 |
| 2 | 1949 | Mar | 132 |
| 3 | 1949 | Apr | 129 |
| 4 | 1949 | May | 121 |
In [71]:
flights.tail()
Out[71]:
| year | month | passengers | |
|---|---|---|---|
| 139 | 1960 | Aug | 606 |
| 140 | 1960 | Sep | 508 |
| 141 | 1960 | Oct | 461 |
| 142 | 1960 | Nov | 390 |
| 143 | 1960 | Dec | 432 |
In [72]:
flights.shape
Out[72]:
(144, 3)
In [73]:
# 연도별 데이터 수
flights['year'].value_counts()
Out[73]:
1949 12
1950 12
1951 12
1952 12
1953 12
1954 12
1955 12
1956 12
1957 12
1958 12
1959 12
1960 12
Name: year, dtype: int64
In [74]:
# 월별 데이터 수
flights['month'].value_counts()
Out[74]:
Jan 12
Feb 12
Mar 12
Apr 12
May 12
Jun 12
Jul 12
Aug 12
Sep 12
Oct 12
Nov 12
Dec 12
Name: month, dtype: int64
연도별 승객수의 변화¶
matplotlib으로 시각화¶
데이터 가공¶
In [75]:
flights.head(1)
Out[75]:
| year | month | passengers | |
|---|---|---|---|
| 0 | 1949 | Jan | 112 |
In [76]:
flights_year = flights.groupby('year')['passengers'].sum()
flights_year
Out[76]:
year
1949 1520
1950 1676
1951 2042
1952 2364
1953 2700
1954 2867
1955 3408
1956 3939
1957 4421
1958 4572
1959 5140
1960 5714
Name: passengers, dtype: int64
시각화¶
In [78]:
plt.plot(flights_year, 'ro--')
plt.xlabel('year')
plt.ylabel('passengers')
plt.show()
seaborn¶
sns.lineplot(data=데이터프레임, x=x축컬럼, y=y축컬럼, estimator=통계함수)
estimator를 생략하면 평균으로 통계를 적용함
- 전체 데이터로 차트를 그리면 신뢰구간 표시
In [112]:
sns.lineplot(data=flights, x='year', y='passengers', errorbar=None, estimator=sum, color='r', marker='o', ls=':')
plt.show()
연도-월별 승객수의 변화¶
matplotlib으로 시각화¶
데이터 가공¶
In [82]:
flights_pivot = flights.pivot(index='year', columns='month', values='passengers')
flights_pivot
Out[82]:
| month | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| year | ||||||||||||
| 1949 | 112 | 118 | 132 | 129 | 121 | 135 | 148 | 148 | 136 | 119 | 104 | 118 |
| 1950 | 115 | 126 | 141 | 135 | 125 | 149 | 170 | 170 | 158 | 133 | 114 | 140 |
| 1951 | 145 | 150 | 178 | 163 | 172 | 178 | 199 | 199 | 184 | 162 | 146 | 166 |
| 1952 | 171 | 180 | 193 | 181 | 183 | 218 | 230 | 242 | 209 | 191 | 172 | 194 |
| 1953 | 196 | 196 | 236 | 235 | 229 | 243 | 264 | 272 | 237 | 211 | 180 | 201 |
| 1954 | 204 | 188 | 235 | 227 | 234 | 264 | 302 | 293 | 259 | 229 | 203 | 229 |
| 1955 | 242 | 233 | 267 | 269 | 270 | 315 | 364 | 347 | 312 | 274 | 237 | 278 |
| 1956 | 284 | 277 | 317 | 313 | 318 | 374 | 413 | 405 | 355 | 306 | 271 | 306 |
| 1957 | 315 | 301 | 356 | 348 | 355 | 422 | 465 | 467 | 404 | 347 | 305 | 336 |
| 1958 | 340 | 318 | 362 | 348 | 363 | 435 | 491 | 505 | 404 | 359 | 310 | 337 |
| 1959 | 360 | 342 | 406 | 396 | 420 | 472 | 548 | 559 | 463 | 407 | 362 | 405 |
| 1960 | 417 | 391 | 419 | 461 | 472 | 535 | 622 | 606 | 508 | 461 | 390 | 432 |
시각화¶
In [83]:
for i in range(12):
plt.plot(flights_pivot.iloc[i], label=flights_pivot.index[i])
plt.legend()
plt.show()
seaborn으로 시각화¶
In [85]:
sns.lineplot(data=flights, x='month', y='passengers', errorbar=None, hue='year')
Out[85]:
<AxesSubplot: xlabel='month', ylabel='passengers'>
데이터의 분포를 나타내는 여러가지 그래프¶
카운트플롯¶
- 데이터의 갯수를 카운트하여 시각화
sns.countplot(data=데이터프레임, x=컬럼)
In [86]:
titanic = sns.load_dataset('titanic')
titanic.head()
Out[86]:
| survived | pclass | sex | age | sibsp | parch | fare | embarked | class | who | adult_male | deck | embark_town | alive | alone | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 0 | 3 | male | 22.0 | 1 | 0 | 7.2500 | S | Third | man | True | NaN | Southampton | no | False |
| 1 | 1 | 1 | female | 38.0 | 1 | 0 | 71.2833 | C | First | woman | False | C | Cherbourg | yes | False |
| 2 | 1 | 3 | female | 26.0 | 0 | 0 | 7.9250 | S | Third | woman | False | NaN | Southampton | yes | True |
| 3 | 1 | 1 | female | 35.0 | 1 | 0 | 53.1000 | S | First | woman | False | C | Southampton | yes | False |
| 4 | 0 | 3 | male | 35.0 | 0 | 0 | 8.0500 | S | Third | man | True | NaN | Southampton | no | True |
In [87]:
# 연령별 승선인원 카운트하여 시각화
plt.figure(figsize=(15,4))
sns.countplot(data=titanic, x='age')
plt.xticks(rotation=90)
plt.grid(axis='y')
plt.show()
In [89]:
# 1. 남자/여자/어린이 승선인원 시각화
# 2. 남자/여자/어린이 별 생존여부
sns.countplot(data=titanic, x='who', hue='alive')
러그플롯¶
sns.rugplot(data=데이터프레임, x=컬럼)
In [91]:
sns.rugplot(data=titanic,x='age', hue='alive')
히스토그램¶
sns.displot(data=데이터프레임, x=컬럼)
In [92]:
iris = sns.load_dataset('iris')
iris.head(1)
Out[92]:
| sepal_length | sepal_width | petal_length | petal_width | species | |
|---|---|---|---|---|---|
| 0 | 5.1 | 3.5 | 1.4 | 0.2 | setosa |
In [93]:
sns.displot(data=iris, x='petal_length', bins=20, rug=True, hue='species', kde=True)
In [94]:
sns.displot(data=iris, x='petal_length', rug=True, hue='species', kind='kde')
Out[94]:
<seaborn.axisgrid.FacetGrid at 0x7f8ba34eb490>
상자수염그래프, 바이올린플롯, 스트립플롯, 스웜플롯¶
- sns.boxplot(data=데이터프레임)
- sns.violinplot(data=데이터프레임)
- sns.stripplot(data=데이터프레임)
- sns.swarmplot(data=데이터프레임)
In [101]:
plt.figure(figsize=(12,8))
plt.subplot(221)
sns.boxplot(data=iris)
plt.subplot(222)
sns.violinplot(data=iris)
plt.subplot(223)
sns.stripplot(data=iris)
plt.subplot(224)
sns.swarmplot(data=iris, s=2)
plt.show()
In [113]:
plt.figure(figsize=(12,8))
plt.subplot(221)
# 박스플롯
sns.boxplot(data=iris, x='species', y='petal_length')
plt.subplot(222)
# 바이올린플롯
sns.violinplot(data=iris, x='species', y='petal_length')
plt.subplot(223)
# 스트립플롯
sns.stripplot(data=iris, x='species', y='petal_length')
plt.subplot(224)
# 스웜플롯
sns.swarmplot(data=iris, x='species', y='petal_length',s=2)
#plt.savefig('day6_12_seabornplots.png')
plt.show()
In [ ]:
'Python' 카테고리의 다른 글
| [python 실습] 인구데이터를 통한 분석 실습 (1) | 2023.03.10 |
|---|---|
| [python 실습] 서울시 폭염/열대야 현황 실습 (1) | 2023.03.10 |
| [python 실습] python을 이용한 데이터 분석 및 시각화 실습 (1) | 2023.03.09 |
| [python 02] 주피터 노트북 사용법 (1) | 2023.03.09 |
| [python 01] 맥북에서 jupyter notebook 설치 (0) | 2023.02.13 |