본문 바로가기
matplot

[파이썬] matplotlib를 활용한 산점도 그래프 그리기

by Sixty Hertz 2020. 2. 21.

[ matplotlib를 활용한 산점도 그래프 그리기 ]

 

산점도 그래프

 

import numpy as np                         # numpy 호출
from matplotlib import pyplot as plt       # matplotlib의 pyplot 모듈 호출

n = 500

X = np.random.rand(n)                      # 0~1사이 n개 난수 생성
Y = np.random.rand(n)                      # 0~1사이 n개 난수 생성
Z = np.arctan2(Y,X)                        # 각 점들의 기울기 계산

plt.scatter(X, Y, c=Z, alpha=0.5)          # 산점도 그래프생성 (c:컬러, alpha:투명도)

plt.show()                                 # 그래프 출력

 

산점도 그래프 생성을 위해 scatter 속성을 사용하며 c는 색상을 의미하는데 각 좌표점들의 기울기에 따라 구별하겠다는 의미입니다.

댓글