使用PyDeck 庫繪製圖表。
這支持 3D Map、點雲等!有關 PyDeck 的更多信息,請訪問 https://deckgl.readthedocs.io/en/latest/ 。
這些文檔也非常有用:
- DeckGL 文檔:https://github.com/uber/deck.gl/tree/master/docs
- DeckGL JSON 文檔:https://github.com/uber/deck.gl/tree/master/modules/json
使用此命令時,我們建議所有用戶使用個人 Mapbox 令牌。這可確保此圖表中使用的Map圖塊更加穩健。您可以使用 mapbox.token 配置選項來執行此操作。
要為自己獲取令牌,請在以下位置創建一個帳戶https://mapbox.com.免費! (適用於中等使用水平)。有關如何設置配置選項的更多信息,請參閱https://docs.streamlit.io/library/advanced-features/configuration#set-configuration-options
函數簽名
st.pydeck_chart(pydeck_obj=None, use_container_width=False)
參數 | 說明 |
---|---|
spec (pydeck.Deck or None) | 指定要繪製的PyDeck 圖表的對象。 |
示例
這是在光照貼圖樣式之上使用HexagonLayer 和ScatterplotLayer 的圖表:
df = pd.DataFrame(
np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4],
columns=['lat', 'lon'])
st.pydeck_chart(pdk.Deck(
map_style='mapbox://styles/mapbox/light-v9',
initial_view_state=pdk.ViewState(
latitude=37.76,
longitude=-122.4,
zoom=11,
pitch=50,
),
layers=[
pdk.Layer(
'HexagonLayer',
data=df,
get_position='[lon, lat]',
radius=200,
elevation_scale=4,
elevation_range=[0, 1000],
pickable=True,
extruded=True,
),
pdk.Layer(
'ScatterplotLayer',
data=df,
get_position='[lon, lat]',
get_color='[200, 30, 0, 160]',
get_radius=200,
),
],
))
相關用法
- Python Streamlit st.pyplot用法及代碼示例
- Python Streamlit st.plotly_chart用法及代碼示例
- Python Streamlit st.progress用法及代碼示例
- Python Streamlit st.experimental_singleton.clear用法及代碼示例
- Python Streamlit st.bokeh_chart用法及代碼示例
- 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.bar_chart用法及代碼示例
- Python Streamlit st.code用法及代碼示例
- Python Streamlit st.experimental_memo.clear用法及代碼示例
- Python Streamlit st.warning用法及代碼示例
- Python Streamlit st.image用法及代碼示例
注:本文由純淨天空篩選整理自streamlit.io大神的英文原創作品 st.pydeck_chart。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。