Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
linogaliana committed Dec 8, 2021
1 parent 9ace7b9 commit 85565d5
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions content/course/modelisation/0_preprocessing.Rmd
Expand Up @@ -166,7 +166,7 @@ En l'occurrence, on peut utiliser `plotly` pour tenir compte de la population:

```{python, include = TRUE, echo=TRUE}
import plotly
import plotly.graph_objects as go
import plotly.graph_objects as pgo
import pandas as pd
import geopandas as gpd
Expand Down Expand Up @@ -195,20 +195,31 @@ colors = ['#FF0000', '#0000FF']
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'],
df['color'] = df['winner'].replace(color_dict)
df['size'] = df['CENSUS_2010_POP']/6000
df['text'] = df["county_name"] + '<br>Population ' + (df['CENSUS_2010_POP']/1e3).astype(str)+' thousands'
fig_plotly = pgo.Figure(
data=pgo.Scattergeo(
locationmode = 'USA-states',
lon=df["lon"], lat=df["lat"],
text = df["text"],
mode = 'markers',
marker_color = df["color"],
marker_size = df['size']
)
)
```

```{python, include = TRUE, echo=TRUE}
fig_plotly.update_traces(
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 Down

0 comments on commit 85565d5

Please sign in to comment.