[부스트캠프 AI Tech 5기] Polar Coordinate

박상우·2023년 3월 27일
0

부스트캠프

목록 보기
25/54
post-thumbnail

Polar Plot

  • 극 좌표계를 사용
  • 회전, 주기성을 표현하기에 적합
  • projection = polar을 추가하여 사용

Radar Chart

  • 극 좌표계를 사용하는 대표적인 차트
  • 별 모양으로 생겨 Star Plot으로 불리기도 함
  • Data의 Quality를 표현하기 좋음

주의

  • 각 Feature는 독립적이며, 척도가 같아야 함
  • 순서형 변수와 수치형 변수가 같이 있다면 하나를 빼는 것을 고려
  • 다각형의 면적이 중요해보이지만 feature의 순서에 따라 많이 달라짐
  • Feature가 많아질수록 가독성이 떨어짐
fig = plt.figure()
ax = fig.add_subplot(111,projection='polar')
plt.show()

Polar Coordinate 조정

fig = plt.figure()
ax = fig.add_subplot(111,projection='polar')

ax.set_rmax(2)
ax.set_rticks([0.5,1,1.5,2])

# 표시 angle 어디로 할지 
ax.set_rlabel_position(angle)

# 좌표계 얼마만큼 표시할 지 
ax.set_thetamin(45)
ax.set_thetamax(135)

plt.show()

Plotting

ax.scatter(theta,r) 
ax.bar(theta,r,width=0.5,alpha=0.5) 
ax.plot(theta,r)
ax.fill(theta,r)
  • polar coordinate의 fill을 적합하게 사용하면 Radar Chart를 사용할 수 있음
stats = ["HP","Attack","Defense","Atk","def","Speed"]
values = [45,49,49,65,65,45]
theta = np.linspace(0,2*np.pi,6,endpoint=False

# 끝 점을 포함하기 위해 마지막 데이터를 포함 
values.append(values[0])
theta  theta.tolist() + [theta[0]]

fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')

ax.plot(theta,values)
ax.fill(theta,values,alpha=0.5)

# Label 그리기 
ax.set_thetagrids([n*60 for n in range(6)], stats)


plt.show()
profile
세상아 덤벼라

0개의 댓글