上下文
创建web应用程序并对图形使用Plotly。我创建了日期滑块,但希望它是一个面积图而不是线图。主图形很好,这不会改变。但是随着越来越多的线被添加,它会添加到滑块中,并且不会使它看起来很漂亮。因此,我想修复日期滑块,将线图(主图)下方作为面积图,但将主图保持为线图。我已经查看了文档,但没有看到任何与此相关的内容
代码:
plotly_fig = px.line(data_frame=dataframe_cols1,x=dataframe_cols1.index,y=Columns_select1)
#width=780, height=830) # Get data from the dataframe with selected columns, choose the x axis as the index of the dataframe, y axis is the data that will be multiselected
# Legend settings
plotly_fig.update_layout(showlegend=True)
plotly_fig.update_layout(margin_autoexpand=True) # prevent size from changing because of legend or anything
plotly_fig.update_traces(mode="lines", hovertemplate=None)
plotly_fig.update_layout(hovermode="x unified")
plotly_fig.update_layout(legend=dict(
orientation = "h",
yanchor="bottom",
y=-.85,
xanchor="right",
x=1.0
))
height = 800
plotly_fig.update_layout(
autosize=False,
width=870,
height=height)
# Date range
plotly_fig.update_xaxes(rangeslider_visible=True,
rangeselector=dict(
buttons=list([
dict(count=1, label="1m", step="month", stepmode="backward"),
dict(count=6, label="6m", step="month", stepmode="backward"),
dict(count=1, label="YTD", step="year", stepmode="todate"),
dict(count=1, label="1y", step="year", stepmode="backward"),
dict(step="all")
])))
st.plotly_chart(plotly_fig,use_container_width=True) # streamlit show graph
问题
这可能吗
它可以通过在不同的轴上绘制不同的轨迹来完成。例如,可以使用
x
和y
轴绘制面积图,其中x
有一个日期滑块。然后可以使用x2
和y2
轴绘制折线图,在这种情况下x2
没有日期滑块。有关示例,请参见下面的代码相关问题 更多 >
编程相关推荐