Coding/데이터 시각화
[Python & Matplotlib] Matplotlib라이브러리를 활용한 산점도 그래프 그리기 !!
포스트it
2024. 2. 28. 09:00
728x90
반응형
[Python & Matplotlib] Matplotlib라이브러리를 활용한 산점도 그래프 그리기 !!
파이썬에서 matplotlib 라이브러리를 사용하여 산점도 그래프를 그리는 예시 입니다 ㅎ
예제코드
import matplotlib.pyplot as plt
import numpy as np
# 데이터 준비
x = np.random.rand(50)
y = np.random.rand(50)
colors = np.random.rand(50)
sizes = 1000 * np.random.rand(50)
# 산점도 그래프 그리기
plt.scatter(x, y, c=colors, s=sizes, alpha=0.5, cmap='viridis')
# 컬러바 추가
plt.colorbar()
# 제목 추가
plt.title("Bubble Scatter Plot")
# 그래프 보여주기
plt.show()
결과
728x90
반응형