0

I have a dataset
enter image description here

data2 = dict(type = 'choropleth',
           locations = df3['Code'],
           z = df3['Power Consumption KWH'])
layout2 = dict(title = '2014 Global Power Consumption',
             geo = dict(showframe = False, projection = {'type': 'natural earth'}))

choromap2 = go.Figure(data = [data2], layout=layout2)
iplot(choromap2)

After that, I created a choropleth, but my problem is the map didn't show any color, it only showed the earth form.
enter image description here

Thanks in advance!

Zephyr
  • 11,891
  • 53
  • 45
  • 80
Vũ Giang
  • 9
  • 1
  • Don't paste the image of the sample data, paste the text version of it – bigbounty Jul 18 '20 at 23:22
  • Add code, errors, and data as text, not screenshots because [Stack Overflow Discourages Screenshots](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors). It is likely the question will be down-voted and closed. You are discouraging assistance because no one wants to retype your data or code, and screenshots are often illegible. [edit] the question and add text. – Trenton McKinney Jul 18 '20 at 23:35
  • Please [create a reproducible copy of the DataFrame with `df.head(20).to_clipboard(sep=',')`](https://stackoverflow.com/questions/52413246/how-to-provide-a-copy-of-your-dataframe-with-to-clipboard), [edit] the question, and paste the clipboard into a code block. – Trenton McKinney Jul 18 '20 at 23:35

1 Answers1

0

I tried to replicate your data and found you are missing one important parameter i.e locationmode = "country names". Adding this should work

data2 = dict(type = 'choropleth',
           locations = df['Code'],
            locationmode = "country names", # add this 
           z = df['Power Consumption KWH'])
layout2 = dict(title = '2014 Global Power Consumption',
             geo = dict(showframe = False, projection = {'type': 'natural earth'}))

choromap2 = go.Figure(data = [data2], layout=layout2)
iplot(choromap2)
bigbounty
  • 16,526
  • 5
  • 37
  • 65