Hi Forum,
I am trying to create a choropleth map with range selector and range slider. Is this possible? My sample code is below.
import plotly.graph_objects as go
import plotly.express as px
import pandas as pd
df = px.data.gapminder()
fig = go.Figure(go.Scattergeo())
fig.add_scattergeo(locations = df['iso_alpha']
,text = df['country']
,marker_color = 'rgb(65, 105, 225)' # blue
,showlegend = False
)
# Set title
fig.update_layout(
title_text="Time series with range slider and selectors"
)
# Add range slider
fig.update_layout(
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(count=1,
label="1y",
step="year",
stepmode="backward"),
dict(count=2,
label="2y",
step="year",
stepmode="backward"),
dict(count=3,
label="3y",
step="year",
stepmode="todate"),
dict(count=4,
label="4y",
step="year",
stepmode="backward"),
dict(step="all")
])
),
rangeslider=dict(
visible=True
),
range=(list(df['year'])[0], list(df['year'])[-1]),
type="Date"
),
)
fig.show()