Streamlit에서 echart를 활용하여 데이터 시각화 하기
Apache ECharts는 직관적이고 대화형이며 사용자 정의가 가능한 차트를
상용 제품에 쉽게 추가할 수 있는 강력한 무료 차트 및 시각화 라이브러리입니다.
https://echarts.apache.org/examples/en/index.html
Examples - Apache ECharts
echarts.apache.org
1. streamlit-echarts 설치
pip install streamlit-echarts
2. 간단한 예제 - bar 그래프
import streamlit as st
from streamlit_echarts import st_echarts
option = {
'xAxis': {
'type': 'category',
'data': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
'yAxis': {
'type': 'value'
},
'series': [
{
'data': [120, 200, 150, 80, 70, 110, 130],
'type': 'bar'
}
]
}
st_echarts(options=option)

3. 간단한 예제 - line 그래프
import streamlit as st
from streamlit_echarts import st_echarts
option = {
'xAxis': {
'type': 'category',
'data': ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
'yAxis': {
'type': 'value'
},
'series': [
{
'data': [150, 230, 224, 218, 135, 147, 260],
'type': 'line'
}
]
};
st_echarts(options=option)

추가적으로 더 다양한 그래프를 접하고 싶다면 아래 공식 페이지에서 예제를 통해 접할 수 있습니다
- 사이트 미리보기

'Python > Streamlit' 카테고리의 다른 글
[Streamlit] 1. Streamlit 시작하기 (0) | 2024.05.17 |
---|