Spaces:
Runtime error
Runtime error
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# @Project : Python. | |
# @File : 995_streamlit_echarts | |
# @Time : 2022/10/17 下午12:11 | |
# @Author : yuanjie | |
# @WeChat : meutils | |
# @Software : PyCharm | |
# @Description : | |
from pyecharts import options as opts | |
from pyecharts.charts import Bar, WordCloud | |
from streamlit_echarts import st_pyecharts | |
import streamlit as st | |
tab1, tab2, tab3 = st.tabs(["Bar", "WordCloud", "Owl"]) | |
with tab1: | |
b = ( | |
Bar() | |
.add_xaxis(["Microsoft", "Amazon", "IBM", "Oracle", "Google", "Alibaba"]) | |
.add_yaxis( | |
"2017-2018 Revenue in (billion $)", [21.2, 20.4, 10.3, 6.08, 4, 2.2] | |
) | |
.set_global_opts( | |
title_opts=opts.TitleOpts( | |
title="Top cloud providers 2018", subtitle="2017-2018 Revenue" | |
), | |
toolbox_opts=opts.ToolboxOpts(), | |
) | |
) | |
st_pyecharts(b) | |
with tab2: | |
pairs = [('中国', 33), | |
('苹果', 24), | |
('奚梦瑶', 20), | |
('美国', 16), | |
('特朗普', 16), | |
('何猷君', 15), | |
('戛纳', 13), | |
('红毯', 12), | |
('iPhone', 12), | |
('车队', 9), | |
('车祸', 9), | |
('优衣', 9), | |
('信息', 9), | |
('李亚鹏', 9), | |
('恋情', 9), | |
('任素', 9), | |
('男孩', 9), | |
('亚洲', 8), | |
('孩子', 8), | |
('大学生', 8)] | |
shapes = ['circle', 'cardioid', 'diamond', 'triangle-forward', 'triangle', 'pentagon', 'star'] | |
wc = ( | |
WordCloud() | |
.add("WordCloud", data_pair=pairs, shape=shapes[0], width='900px', height='500px') | |
.set_global_opts( | |
title_opts=opts.TitleOpts( | |
title="WordCloud", subtitle="WordCloud" | |
), | |
toolbox_opts=opts.ToolboxOpts(), | |
) | |
) | |
st_pyecharts(wc) | |