借助st.plotly_chart实现
官方介绍:st.plotly_chart
案例:
import pandas as pd
import plotly.graph_objs as go
import plotly.express as px
st.subheader("课题组成员", divider='red')
df = pd.read_excel("./data/summary.xlsx", sheet_name="people")
colors = ['55CBF2', '#8BE09C', '#FFC573', '#FF9DB5', ] # 颜色设置
D = go.Pie(values=df.iloc[:, 2], labels=df.iloc[:, 1], hole=0.5, name="课题组各学历人数占比",marker=dict(colors=colors, line=dict(color='white', width=2)))
F = go.Figure(data=D)
st.plotly_chart(F, use_container_width=True)
效果:
其他类型图表使用介绍:
Plotly express in Python