顯示條形圖。
這隻是 st.altair_chart 周圍的syntax-sugar。主要區別在於此命令使用數據自己的列和索引來確定圖表的規格。因此,這更容易用於許多“隻是繪製這個”場景,同時不太可定製。
如果 st.bar_chart 沒有正確猜測數據規範,請嘗試使用 st.altair_chart 指定所需的圖表。
函數簽名
st.bar_chart(data=None, width=0, height=0, use_container_width=True)
參數 | 說明 |
---|---|
data (pandas.DataFrame, pandas.Styler, pyarrow.Table, numpy.ndarray, Iterable, or dict) | 要繪製的數據。 Streamlit 的舊版 DataFrame 序列化(即使用 |
width (int) | 圖表寬度(以像素為單位)。如果為 0,則自動選擇寬度。 |
height (int) | 圖表高度(以像素為單位)。如果為 0,則自動選擇高度。 |
use_container_width (bool) | 如果為 True,則將圖表寬度設置為列寬。這優先於寬度參數。 |
示例
chart_data = pd.DataFrame(
np.random.randn(50, 3),
columns=["a", "b", "c"])
st.bar_chart(chart_data)
相關用法
- Python Streamlit st.balloons用法及代碼示例
- Python Streamlit st.bokeh_chart用法及代碼示例
- Python Streamlit st.button用法及代碼示例
- Python Streamlit st.experimental_singleton.clear用法及代碼示例
- Python Streamlit st.caption用法及代碼示例
- Python Streamlit st.text_input用法及代碼示例
- Python Streamlit st.area_chart用法及代碼示例
- Python Streamlit st.title用法及代碼示例
- Python Streamlit st.cache用法及代碼示例
- Python Streamlit st.experimental_singleton用法及代碼示例
- Python Streamlit st.empty用法及代碼示例
- Python Streamlit st.error用法及代碼示例
- Python Streamlit st.video用法及代碼示例
- Python Streamlit st.vega_lite_chart用法及代碼示例
- Python Streamlit st.slider用法及代碼示例
- Python Streamlit st.header用法及代碼示例
- Python Streamlit st.container用法及代碼示例
- Python Streamlit st.form_submit_button用法及代碼示例
- Python Streamlit st.form用法及代碼示例
- Python Streamlit st.plotly_chart用法及代碼示例
- Python Streamlit st.code用法及代碼示例
- Python Streamlit st.experimental_memo.clear用法及代碼示例
- Python Streamlit st.warning用法及代碼示例
- Python Streamlit st.image用法及代碼示例
- Python Streamlit st.markdown用法及代碼示例
注:本文由純淨天空篩選整理自streamlit.io大神的英文原創作品 st.bar_chart。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。