시작하기무료로 시작하기

시간대별 판매 제품

베이커리는 하루 중 다양한 시간대에 얼마나 많은 제품이 판매되는지 보고 싶어 해요.

HoverTool이 포함된 그림 fig가 미리 설정되어 있으며, 여기에는 시간대, 상품명, 판매 수량이 표시돼요.

이제 이해관계자가 의미를 바로 파악할 수 있도록 범례에 제목을 추가하고, 관측값을 가리지 않도록 범례 위치를 조정하며, 클릭하면 해당 관측값을 숨길 수 있도록 범례를 변경하세요.

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

Bokeh로 배우는 인터랙티브 데이터 시각화

강의 보기

연습 안내

  • 범례 제목을 "Time of Day"로 추가하세요.
  • 범례를 왼쪽 위 모서리로 이동하세요.
  • 범례 라벨을 클릭하면 해당 관측값이 숨겨지도록 범례를 상호작용형으로 설정하세요.

실습형 인터랙티브 연습

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

fig = figure(x_axis_label="Count of Products Sold", y_axis_label="Sales", title="Bakery Product Sales", tooltips=TOOLTIPS)
fig.circle(x="count", y="sales", source=morning, line_color="red", size=12, fill_alpha=0.4, legend_label="Morning")
fig.circle(x="count", y="sales", source=afternoon, fill_color="purple", size=10, fill_alpha=0.6, legend_label="Afternoon")
fig.circle(x="count", y="sales", source=evening, fill_color="yellow", size=8, fill_alpha=0.6, legend_label="Evening")

# Add legend title
fig.____.____ = "____"

# Move the legend
fig.____.____ = "____"

# Make the legend interactive
fig.____.____ = "____"
fig.yaxis[0].formatter = NumeralTickFormatter(format="$0.00")
output_file("Sales_by_time_of_day")
show(fig)
코드 편집 및 실행