시작하기무료로 시작하기

가독성 높이기

여러분과 동료들은 보여 주려는 데이터에서 가장 중요한 점이 가장 "시장 친화적인" 주인 Vermont와 가장 그렇지 않은 Texas의 차이라는 데에 의견을 모았습니다. 이를 위해 두 개의 플롯을 나란히 배치하세요 – 각 주의 농산물 직거래 장터(farmer's market)당 인구수를 보여 주는 막대그래프와, x축에 인구수, y축에 시장 수를 놓은 산점도입니다.

Vermont와 Texas에 뚜렷한 색을 지정해 강조하세요. 또한 Texas에 대해 크고 읽기 쉬운 주석도 추가하세요.

Vermont와 Texas에는 고유한 색을, 다른 모든 주에는 회색을 할당한 색상 벡터 state_colors와 Texas를 설명하는 주석 tx_message가 제공됩니다.

이 연습은 강의의 일부입니다

Python으로 데이터 시각화 개선하기

강의 보기

연습 안내

  • 제공된 색상 벡터 state_colorssns.barplot()palette 인자로 전달해 막대그래프(ax1)에 매핑하세요.
  • 산점도 점에는 인자 c로 색상 벡터를 매핑하세요.
  • 주석 텍스트의 크기를 15로 변경해 읽기 쉽게 만드세요.

실습형 인터랙티브 연습

이 예제를 이 샘플 코드를 완성하여 풀어보세요.

# Draw barplot w/ colors mapped to state_colors vector
sns.barplot('people_per_market', 'state', ____ = ____,
            data = markets_by_state, ax = ax1)

# Map state colors vector to the scatterplot as well
p = sns.scatterplot('population', 'num_markets', c = ____,
                    data = markets_by_state, s = 60, ax = ax2)

# Log the x and y scales of our scatter plot so it's easier to read
ax2.set(xscale = "____", yscale = '____')

# Increase annotation text size for legibility
ax2.annotate(tx_message, xy = (26956958,230), 
             xytext = (26956958, 450),ha = 'right', 
             size = ____, backgroundcolor = 'white',
             arrowprops = {'facecolor':'black', 'width': 3})
sns.set_style('whitegrid')
plt.show()
코드 편집 및 실행