下面是我的代码:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
import plotly.express as px
import streamlit as st
#index is date
fig1 = px.line(plot_df2,y=['price','counting'],template="plotly_dark"})
fig2 = px.line(plot_df3,y=['price','counting'],template="plotly_dark")
fig = make_subplots(rows=1, cols=2)
fig.add_trace(fig1['data'][0], row=1, col=1)
fig.add_trace(fig1['data'][1], row=1, col=1)
fig.add_trace(fig2['data'][0], row=1, col=2)
fig.add_trace(fig2['data'][1], row=1, col=2
st.plotly_chart(fig, theme=None, use_container_width=True)
我想添加标签,如价格和计数和图例,如'数据集绘图'到代码中,我该怎么做?
先谢了
1条答案
按热度按时间4c8rllxm1#
你可以在
update_layout
的帮助下完成这个任务,这会给两个子图添加标签和图例。