# Choropleth map is generated but, not plotting data

**URL:** https://community.plotly.com/t/choropleth-map-is-generated-but-not-plotting-data/13833
**Category:** 📊 Plotly Python
**Created:** [September 21, 2018, 9:50pm UTC](https://community.plotly.com/t/choropleth-map-is-generated-but-not-plotting-data/13833 "2018-09-21T21:50:25Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![iiWylde](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiWylde](https://community.plotly.com/u/iiWylde)
#### Post date: [September 21, 2018, 9:50pm UTC](https://community.plotly.com/t/choropleth-map-is-generated-but-not-plotting-data/13833/1 "2018-09-21T21:50:25Z")

</div>

I am trying to make a choropleth map that has a slider so that it I can look at different years. The map, slider, and side bar for the values appear but, there is not color on the map. Also when I use the slider the side bar values disappear. Here is my code.

```
df_summed = df_pre_2003.groupby(['StateName']) ['nAllNeonic'].sum().reset_index()
yrs=['1992', '1993', '1994','1995','1996',
         '1997', '1998', '1999', '2000', '2001','2002','2003']
data = dict(type = 'choropleth', 
           locations = df_summed.StateName,
           locationmode = 'USA-states',
           z = df_summed.nAllNeonic, 
           text = df_summed.StateName,
           colorbar = {'title':'Neonics'},
            )
steps = []
year = 0
for i in range (0,len(data)):
    step = dict(method = "restyle",
                args = ["visible", [False]*len(data)],
                label = yrs[year]) 
    step['args'][1][i] = True
    steps.append(step)
    year += 2

sliders = [dict(active = 10,
                currentvalue = {"prefix": "Year: "},
                pad = {"t": 50},
                steps = steps)]
layout = dict(title = 'Neonic Usage 2003 and before', 
             geo = dict(showframe = False, 
                       projection = {'type': 'albers usa'}),
             sliders=sliders)
#fig = dict(data=data, layout=layout)
#iplot(fig)
choromap3 = go.Figure(data = [data], layout=layout)
iplot(choromap3)

```

The output is:  
 ![Screenshot%20(84)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/1/1184ad5e1dd0ab16604d5e78c073196df112d74a.png)

Here is what I am talking about when the side values disappear.  
 ![Screenshot%20(85)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/9/90af4a4610c42c273b89b7450ca2ffc609301e21.png)

---

<div class="post-metadata">

### Author: ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)
#### Post date: [September 22, 2018, 9:35am UTC](https://community.plotly.com/t/choropleth-map-is-generated-but-not-plotting-data/13833/2 "2018-09-22T09:35:53Z")

</div>

Hi @iiWylde,

I don’t know if this is the whole problem, but it looks like you’re creating a single trace (`data`) but your `steps` list seems to assume that you have one trace per year (based on how you set the `"visible"` arg).

Can you successfully create a `choropleth` for a single year, without the slider?

-Jon

---

<div class="post-metadata">

### Author: ![iiWylde](https://avatars.discourse-cdn.com/v4/letter/i/8baadc/32.png) [@iiWylde](https://community.plotly.com/u/iiWylde)
#### Post date: [September 23, 2018, 2:54am UTC](https://community.plotly.com/t/choropleth-map-is-generated-but-not-plotting-data/13833/3 "2018-09-23T02:54:00Z")

</div>

Unfortunately I can not. I’ve tried a few things and it just gives me a blank map.  
The code for one map is:  
df\_summed = df\_pre\_2003.groupby([‘StateName’]) [‘nAllNeonic’].sum().reset\_index()

> ```
> > data = dict(type = 'choropleth', 
> > locations = df_summed.StateName,
> > locationmode = 'USA-states',
> > z = df_summed.nAllNeonic, 
> > #text = df_summed.StateName,
> > colorbar = {'title':'Neonics'},
> > )
> > layout = dict(title = 'Neonic Usage 2003 and before', 
> > geo = dict(showframe = False, 
> > projection = {'type': 'albers usa'}))
> > #fig = dict(data=data, layout=layout)
> > #iplot(fig)
> > choromap3 = go.Figure(data = [data], layout=layout)
> > iplot(choromap3)
> 
> ```

Which just provides a blank map with the data scale on the side (first image in post.)  
Here is what I am working with for the data.

 ![Screenshot%20(86)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/2/2613af6698d2d4cb43db757e13234ba77bd41e95.png)

---

<div class="post-metadata">

### Author: ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)
#### Post date: [September 23, 2018, 12:45pm UTC](https://community.plotly.com/t/choropleth-map-is-generated-but-not-plotting-data/13833/4 "2018-09-23T12:45:05Z")

</div>

Hi @iiWylde,

Could you make your code example self-contained by adding imports and a variable declaration for `df_summed` that includes some of the relevant data (you don’t need to type in the whole series, just include enough states for people to get a feel for what it should look like)? It will be much easier for folks to try to help you if they can copy and paste your code and start off seeing the same behavior you’re seeing.

Thanks!  
-Jon
