Skip to content

Commit

Permalink
évite la boucle crado
Browse files Browse the repository at this point in the history
  • Loading branch information
linogaliana committed Dec 7, 2021
1 parent 3514e09 commit 9ace7b9
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions content/course/modelisation/0_preprocessing.Rmd
Expand Up @@ -192,24 +192,23 @@ colors = ['#FF0000', '#0000FF']
```

```{python, include = TRUE, echo=TRUE}
fig_plotly = go.Figure()
for i in range(2):
tempdf = df.loc[df['winner'].astype(str) == limits[i]]
fig_plotly.add_trace(go.Scattergeo(
locationmode = 'USA-states',
lon = tempdf['lon'],
lat = tempdf['lat'],
text = tempdf['text'],
name = 'Winner: {}'.format(limits[i]),
marker = dict(
size = tempdf['CENSUS_2010_POP']/6000,
color = colors[i],
opacity=0.5,
line_color='rgb(40,40,40)',
line_width=0.5,
sizemode = 'area'
)))
df['color'] = df['winner'].replace(color_dict)
df['size'] = df['CENSUS_2010_POP']/6000
fig_plotly = go.Figure(data=go.Scattergeo(
locationmode = 'USA-states',
lon=df["lon"], lat=df["lat"],
text = df["text"],
mode = 'markers',
marker_color = df["color"],
marker_size = df['size'],
marker = dict(
opacity=0.5,
line_color='rgb(40,40,40)',
line_width=0.5,
sizemode = 'area'
)
))
fig_plotly.update_layout(
title_text = "Reproduction of the \"Acres don't vote, people do\" map <br>(Click legend to toggle traces)",
Expand All @@ -219,7 +218,6 @@ fig_plotly.update_layout(
landcolor = 'rgb(217, 217, 217)',
)
)
```


Expand Down

0 comments on commit 9ace7b9

Please sign in to comment.