最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to display a dash leaflet colorbar horizontally? - Stack Overflow

programmeradmin2浏览0评论

I'm buiding an application in dash that contains a map. This map is build using the dash-leaflet lib. I would like to have the colorbar displayed horizontally instead of vertically, is it possible and if yes what should I add to my code ?

import dash_leaflet as dl
from dash import Dash

colorscale = ['red', 'yellow', 'green', 'blue', 'purple']  # rainbow
app = Dash()
app.layout = dl.Map([
    dl.TileLayer(),
    dl.Colorbar(
        colorscale=colorscale,
        width=20,
        height=200,
        min=0,
        max=50,
        position="bottomleft"
    )
], center=[56, 10], zoom=6,  style={'height': '100vh'})

if __name__ == "__main__":
    app.run_server()

I'm buiding an application in dash that contains a map. This map is build using the dash-leaflet lib. I would like to have the colorbar displayed horizontally instead of vertically, is it possible and if yes what should I add to my code ?

import dash_leaflet as dl
from dash import Dash

colorscale = ['red', 'yellow', 'green', 'blue', 'purple']  # rainbow
app = Dash()
app.layout = dl.Map([
    dl.TileLayer(),
    dl.Colorbar(
        colorscale=colorscale,
        width=20,
        height=200,
        min=0,
        max=50,
        position="bottomleft"
    )
], center=[56, 10], zoom=6,  style={'height': '100vh'})

if __name__ == "__main__":
    app.run_server()

Share Improve this question asked Mar 11 at 13:43 Pierrick RambaudPierrick Rambaud 2,5212 gold badges26 silver badges74 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The lib is more clever than I thought, simply set a bigger width than height values and the colorbar will become horizontal:

import dash_leaflet as dl
from dash import Dash

colorscale = ['red', 'yellow', 'green', 'blue', 'purple']  # rainbow
app = Dash()
app.layout = dl.Map([
    dl.TileLayer(),
    dl.Colorbar(
        colorscale=colorscale,
        width=200,
        height=20,
        min=0,
        max=50,
        position="bottomleft"
    )
], center=[56, 10], zoom=6,  style={'height': '100vh'})

if __name__ == "__main__":
    app.run_server()

发布评论

评论列表(0)

  1. 暂无评论