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 | 29 | 30 | 31 |
Tags
- stable diffusion
- 논문 리뷰
- kt인적성
- Generative Models
- 포스코 채용
- colorization
- ddim
- controlNet
- Image Generation
- classifier-free guidance
- DDPM
- posco 채용
- 과제형 코딩테스트
- ip-adapter
- 포스코 코딩테스트
- 프로그래머스
- dp
- manganinja
- 코딩테스트
- KT
- diffusion models
Archives
- Today
- Total
Paul's Grit
[Python] [Data Visualization] matplotlib 기초 본문
Matplotlib¶
In [2]:
import matplotlib.pyplot as plt
import koreanize_matplotlib
import numpy as np
01. 기본 그래프¶
In [3]:
datas = [1, 2, 3, 4, 7, 4, 8, 9, 2, 3]
In [8]:
plt.figure(figsize=(3, 3)) # figsize 사이즈 조절, 단위: 인치
plt.plot(datas)
plt.show()
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
In [29]:
x_datas = np.arange(0, 200, 20)
y_datas = np.random.randint(10, size=10)
In [33]:
plt.figure(figsize=(5, 5))
plt.bar(x_datas, y_datas)
plt.title('Graph practice')
plt.xlabel('xaxis')
plt.ylabel('ylabel')
plt.show()
In [ ]:
plt.figure(figsize=(5, 5))
plt.plot*
02. 스타일¶
In [38]:
plt.figure(figsize=(3, 3))
plt.plot(y_datas, 'r^-.') # 'r^-.' 이런 식으로도 한번에 그래프 디자인 변경 가능
plt.show() # 처음부터 그래프 디자인에 너무 집착하지는 말자
In [45]:
plt.figure(figsize=(3, 3))
plt.plot(y_datas, c='r', lw=3, ls=':', marker='*', mec='r', mew=2, mfc='b')
plt.show()
03. 축 설정¶
In [50]:
plt.figure(figsize=(5, 2))
plt.plot(y_datas)
plt.xlim(-2, 11)
plt.ylim(-2, 15)
plt.show()
In [54]:
plt.figure(figsize=(5, 3))
plt.plot(y_datas, 'r^-.')
plt.xticks(range(0, 10))
plt.yticks(range(0, 11, 5))
plt.show()
04. 그래프 여러 개 그리기¶
In [60]:
first = np.random.randint(10, size=5)
second = np.random.randint(10, size=5)
third = np.random.randint(10, size=5)
In [63]:
plt.figure(figsize=(3, 3))
plt.plot(first)
plt.plot(second)
plt.plot(third)
plt.show()
In [66]:
datas = [np.random.randint(10, size=10) for _ in range(3)]
print(datas)
[array([0, 8, 8, 9, 9, 6, 1, 1, 2, 8]), array([2, 3, 8, 1, 8, 5, 0, 0, 4, 8]), array([7, 2, 0, 5, 9, 8, 9, 4, 7, 7])]
In [75]:
plt.figure(figsize=(5, 5))
plt.plot(datas[0], 'ro--')
plt.plot(datas[1], 'b*--')
plt.plot(datas[2], 'g^--')
plt.grid()
plt.show()
In [74]:
# 참고: 한줄로 그릴 수도 있다
plt.figure(figsize=(3, 3))
plt.plot(datas[0], 'ro--', datas[1], 'b*--', datas[2], 'g^--')
plt.show()
In [79]:
plt.figure(figsize=(5, 5))
plt.plot(datas[0], label='First')
plt.plot(datas[1], label='Second')
plt.plot(datas[2], label='Third')
plt.grid()
plt.legend(loc='upper left')
plt.show()
In [81]:
# 10개 길이
datas = [np.random.randint(10, size=10) for _ in range(10)]
len(datas)
Out[81]:
10
In [89]:
plt.figure(figsize=(5, 5))
for i in range(len(datas)):
plt.plot(datas[i], label=f'Data {i}')
plt.legend(loc='upper right')
plt.show()
In [107]:
plt.figure(figsize=(20, 5))
plt.subplot(121) # 1개의 행, 2개의 열, 현재 첫번째 위치
plt.plot(datas[0])
plt.subplot(122) # 1개의 행, 2개의 열, 현재 두번째 위치
plt.plot(datas[1])
plt.plot()
Out[107]:
[]
'Data Analysis > Visualization' 카테고리의 다른 글
[Python] [Data Analysis] Naver 검색 API 사용한 쇼핑 데이터 분석 (0) | 2023.08.11 |
---|---|
[Python] [Data Visualization] Geocode AIP를 사용하여 위치 정보 불러오기 (1) | 2023.08.10 |
[Python] [Data Visualization] 지도 시각화 도구 Folium (0) | 2023.08.10 |
[Python] [Data Visualization] seaborn을 활용한 데이터 시각화 기초 (2) | 2023.08.08 |
[Python] [Data Visualization] matplotlib Documentation Examples (1) | 2023.08.08 |