Create country choropleth hover regression
See original GitHub issueOriginally reported at https://community.plot.ly/t/county-choropleths-not-displaying-hoverinfo-in-offline-mode/19241
The hover tooltips for the figure produced by create_choropleth
are sometimes not being displayed properly with recent versions of plotly.js.
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'
)
Plotting this figure in the most recent version of plotly.js (1.44.3) results in no hover tooltips
py.offline.plot(fig,
filename='choropleth_california_and_surr_states_outlines',
include_plotlyjs='https://cdn.plot.ly/plotly-1.44.3.min.js')
But using 1.42.3 the tooltips are dipslayed as expected
py.offline.plot(fig,
filename='choropleth_california_and_surr_states_outlines',
include_plotlyjs='https://cdn.plot.ly/plotly-1.42.3.min.js')
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to step up your Folium Choropleth Map skills
To create a choropleth, we need two things: First, we need a geoJSON file that gives us the geographical coordinates for the layers....
Read more >Creating a Choropleth Map of State Unemployment Rates ...
This data can be sourced to create a choropleth map that highlights the differences in labor market conditions across the country using ...
Read more >Choropleth Maps Using Python - DevSkrol
To make a Choropleth Map, we need two main types of inputs. ... GeoJSON-formatted geometry information can be obtained either using FIPS IDs...
Read more >Beautiful Interactive Choropleth & Scatter Maps with Plotly
R Maps: Beautiful Interactive Choropleth & Scatter Maps with PlotlyTimeline0:00 Intro0:28 Reading in data ( Choropleth )1:44 Building base ...
Read more >Free Choropleth Map Maker - Displayr
The simplest way to create and customize choropleth maps ... Connect or paste your list of geographic entities (countries, continents, states, regions, or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like the bug creates duplicate hover tooltips and stores their
x
,y
coordinates as lists instead of floats.e.g.
instead of
De-duplicating and flattening restores functionality. Building on the code snippet from @jonmmease’s original post…
Any update on when this bug might be fixed?