Search code examples
pythonplotly

Zoom map and set colorbar horizontal in plotly python


I'm using plotly in python to draw a map. After drawing, I export to a png file.

enter image description here

Now I want to make the map bigger or zoom the map and set the colorbar horizontal and below the map. Could anyone show me how to do it?


Solution

  • You can try the following and experiment with the parameters to zoom into the image. One drawback is that the colorbar could get zoomed too. But it is a good place to start.

    fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
    

    Parameters:

    t - Sets the top margin (in px); default=80

    r - Sets the right margin (in px); default=80

    b - Sets the bottom margin (in px); default=80

    l - Sets the left margin (in px); default=80

    References:

    1. https://plotly.com/python/choropleth-maps/
    2. https://plotly.com/python/reference/layout/#layout-margin