'Reposition Colorbar plotly express / graph object Maps
I am trying to move / reposition the colorbar. I overlay multiple layers of spatial data on the map, and the colorbar overlaps with eachother. I'd like to be able to reposition the colorbars.
I am using the US counties GeoJSON file from: https://eric.clst.org/tech/usgeojson/
import pandas as pd
import geopandas as gpd
import mapbox
from plotly import graph_objs as go
from plotly.graph_objs import *
# Update with host url
df_geo = gpd.read_file('https://raw.githubusercontent.com/host')
import plotly.graph_objects as go
fig = go.Figure(go.Choroplethmapbox(geojson=df_geo['geometry'].to_json(),
locations=df_geo['NAME'],
z=df_geo['CENSUSAREA'],
autocolorscale=False,
colorscale="Viridis",
zmin=df_geo['CENSUSAREA'].min(),
zmax=df_geo['CENSUSAREA'].max(),
marker_line_width=0))
fig.update_layout(mapbox_style="light",
mapbox_accesstoken=token,
mapbox_zoom=3,
mapbox_center = {"lat": 37.0902, "lon": -95.7129},
margin={"r":0,"t":0,"l":0,"b":0})
fig.update_layout()
fig.show()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|