import plotly.graph_objects as go
from plotly.subplots import make_subplots
= make_subplots(rows=1, cols = 2)
fig
=[1, 2, 3], y=[4, 5, 6], name="subplot 1"),
fig.add_trace(go.Scatter(x=1, col=1)
row=[10, 20, 30], y=[100, 200, 300], name="subplot 2"),
fig.add_trace(go.Scatter(x=1, col=2)
row
fig.show()
Plotly Subpolt 만들기
Plotly Subpolt 만들기
Data Visualization
Plotly Subplt 만들기
Plotly Subplot
Python으로 여러개의 그래프를 비교하기 좋은 방법은 subplot을 이용한 방법인 것 같습니다. subplot을 만드는 방법과 subplot의 title작성하는 방법 그리고 subplot들에 대한 전체 title을 넣는 방법도 함께 정리합니다.
Plotly의 make_subplots
함수로 subplot을 구성하고 ploty 그래프를 생성했습니다. add_trace()
함수로 생성한 subplot에 그래프를 추가합니다.
Subplot 세부설정
make_subplot의 세부 설정을 알아보고 어떻게 변경할 수 있는지 알아봅니다. 하나의 Y축을 2개의 subplot이 공유하도록 shared_yaxes
를 사용합니다. 각각의 subplot의 크기는 column_widths
로 변경할 수 있습니다. 2개의 subplot사이의 거리는 horizontal_spacing
으로 정합니다.
import plotly.graph_objects as go
from plotly.subplots import make_subplots
= make_subplots(
fig =1, cols=2,
rows=True,
shared_yaxes=0.05,
horizontal_spacing=[0.3, 0.7]
column_widths
)
=[1, 2, 3], y=[4, 5, 6], name="subplot 1"),
fig.add_trace(go.Scatter(x=1, col=1)
row=[10, 20, 30], y=[10, 20, 30], name="subplot 2"),
fig.add_trace(go.Scatter(x=1, col=2)
row
fig.show()
참고
- https://chancoding.tistory.com/229
Date | Title | Author |
---|---|---|
Jan 1, 3000 | 전체 카테고리 | |
Aug 18, 2024 | Folium에서 Google Map 사용 방법 | |
Aug 16, 2024 | Folium의 Choropleth 지도 | |
Aug 15, 2024 | Folium 마커 생성과 색상 변경하기 | |
Oct 8, 2023 | Plotly line, shape 그리기 | |
Oct 5, 2023 | Plotly Funnel(깔대기) 차트 만들기 | |
Oct 4, 2023 | Plotly 차트의 축 tick 회전 및 폰트 변경하기 | |
Oct 3, 2023 | Plotly 불릿차트 | |
Oct 2, 2023 | Plotly Hover 설정하기 | |
Sep 30, 2023 | Plotly Axis 포멧 변경하기 | |
Sep 28, 2023 | Plotly 마커 모양 변경하기 | |
Sep 25, 2023 | Plotly Time Series 날짜 범위 UI 사용하기 | |
Sep 22, 2023 | Plotly Line Plot만들기 | |
Sep 21, 2023 | Plotly Histogram Plot만들기 | |
Sep 18, 2023 | Plotly Animation 만들기 | |
Sep 18, 2023 | Plotly Box Plot만들기 | |
Sep 17, 2023 | Plotly Treemap 만들기 | |
Sep 17, 2023 | Plotly Bubble chart 만들기 |
No matching items