다른 사람과 공유할 그림 준비하기

Matplotlib으로 시작하는 데이터 시각화

Ariel Rokem

Data Scientist

플롯 스타일 변경하기

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"])
ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"])
ax.set_xlabel("Time (months)")
ax.set_ylabel("Average temperature (Fahrenheit degrees)")
plt.show()

Matplotlib으로 시작하는 데이터 시각화

스타일 선택하기

plt.style.use("ggplot")

fig, ax = plt.subplots() ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"]) ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"]) ax.set_xlabel("Time (months)") ax.set_ylabel("Average temperature (Fahrenheit degrees)") plt.show()

Matplotlib으로 시작하는 데이터 시각화

기본값으로 되돌리기

plt.style.use("default")
Matplotlib으로 시작하는 데이터 시각화

사용 가능한 스타일

Matplotlib으로 시작하는 데이터 시각화

"bmh" 스타일

plt.style.use("bmh")

fig, ax = plt.subplots() ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"]) ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"]) ax.set_xlabel("Time (months)") ax.set_ylabel("Average temperature (Fahrenheit degrees)") plt.show()

Matplotlib으로 시작하는 데이터 시각화

Seaborn 스타일

plt.style.use("seaborn-colorblind")

fig, ax = plt.subplots() ax.plot(seattle_weather["MONTH"], seattle_weather["MLY-TAVG-NORMAL"]) ax.plot(austin_weather["MONTH"], austin_weather["MLY-TAVG-NORMAL"]) ax.set_xlabel("Time (months)") ax.set_ylabel("Average temperature (Fahrenheit degrees)") plt.show()

Matplotlib으로 시작하는 데이터 시각화

플로팅 스타일 선택 가이드

  • 어두운 배경은 대개 가시성이 낮습니다
  • 색이 중요하다면 색각이상 친화 팔레트를 고려하세요
    • "seaborn-colorblind" 또는 "tableau-colorblind10"
  • 인쇄 가능성을 염두에 둔다면 잉크 사용을 줄이세요
  • 흑백 인쇄라면 "grayscale" 스타일을 쓰세요
Matplotlib으로 시작하는 데이터 시각화

나에게 맞는 스타일을 골라 연습해 보세요!

Matplotlib으로 시작하는 데이터 시각화

Preparing Video For Download...