【问题标题】:how to create a grouped bar chart in streamlit如何在 Streamlit 中创建分组条形图
【发布时间】:2022-11-16 06:02:22
【问题描述】:

如何在 Streamlit 中创建分组条形图 我试过 st.altair(chart) 方法来得到答案,但它仍然显示堆积条形图而不是分组条形图

【问题讨论】:

  • iscuss.streamlit.io/t/how-to-graph-a-grouped-bar-chart-on-streamlit/17957/3
  • 这些方法我都试过了还是不行
  • 你能分享你到目前为止尝试过的代码吗?

标签: python streamlit


【解决方案1】:

你应该能够 create the bar chart with Altair 然后将它传递给 Streamlit:

chart = alt.Chart(prediction_table2, title='Simulated (attainable) and predicted yield ').mark_bar(
    opacity=1,
    ).encode(
    column = alt.Column('date:O', spacing = 5, header = alt.Header(labelOrient = "bottom")),
    x =alt.X('variable', sort = ["Actual_FAO", "Predicted", "Simulated"],  axis=None),
    y =alt.Y('value:Q'),
    color= alt.Color('variable')
).configure_view(stroke='transparent')

st.altair_chart(chart)

【讨论】:

    猜你喜欢
    • 2018-05-27
    • 1970-01-01
    • 1970-01-01
    • 2016-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多