I’m trying to make an offline county choropleth map, but nothing is shown when I hover over the map unless I plot it in online mode.
This example from USA County Choropleth Maps tutorials doesn’t display any hoverinfo for me:
import plotly as py
import plotly.figure_factory as ff
import numpy as np
import pandas as pd
df_sample = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/minoritymajority.csv')
df_sample_r = df_sample[df_sample['STNAME'] == 'California']
values = df_sample_r['TOT_POP'].tolist()
fips = df_sample_r['FIPS'].tolist()
colorscale = [
'rgb(193, 193, 193)',
'rgb(239,239,239)',
'rgb(195, 196, 222)',
'rgb(144,148,194)',
'rgb(101,104,168)',
'rgb(65, 53, 132)'
]
fig = ff.create_choropleth(
fips=fips, values=values, scope=['CA', 'AZ', 'Nevada', 'Oregon', ' Idaho'],
binning_endpoints=[14348, 63983, 134827, 426762, 2081313], colorscale=colorscale,
county_outline={'color': 'rgb(255,255,255)', 'width': 0.5}, round_legend_values=True,
legend_title='Population by County', title='California and Nearby States'
)
py.offline.plot(fig, filename='choropleth_california_and_surr_states_outlines')
However, hoverinfo does work with a simpler example from the tutorial if I use py.offline.plot(fig, validate=False)
, but validate=False
doesn’t help my other plots.
import plotly as py
import plotly.figure_factory as ff
fips = ['06021', '06023', '06027',
'06029', '06033', '06059',
'06047', '06049', '06051',
'06055', '06061']
values = range(len(fips))
fig = ff.create_choropleth(fips=fips, values=values)
py.offline.plot(fig, validate=False)
Does anyone know what I’m doing wrong or if this isn’t something supported with the python library in offline mode?
Thank you!