Python으로 배우는 Plotly 데이터 시각화 입문
Alex Scriven
Data Scientist
$$

add_trace() 사용$$
$$
add_trace() 사용
$$
$$
$$

from plotly.graph_objects import Figure layered_fig = Figure()bar_fig = px.bar(df, x='Date' , y='Quarterly Growth (%)')line_fig = px.line(df, x='Date' , y='Rolling YTD Growth (%)' , color_discrete_sequence=['red'])layered_fig = Figure(data= [*bar_fig.data, *line_fig.data]) layered_fig.show()

# 같은 bar_fig, line_fig 작성 line_fig2 = px.line(df, x='Date' , y='OECD Average GDP Growth (%)' , color_discrete_sequence=['green'])layered_fig = Figure(data= [*bar_fig.data , *line_fig.data, *line_fig2.data]) layered_fig.show()

# 두 개의 figure로 생성 layered_fig = Figure(data=[*bar_fig.data, *line_fig.data])# 마지막 선 추가 layered_fig.add_trace(line_fig2.data[0])
Python으로 배우는 Plotly 데이터 시각화 입문