2011 Executions by State

In [2]:
import plotly.graph_objects as go

import pandas as pd

df = pd.read_csv('2011_executions.csv')
df.head()

df['text'] = df['name'] + '<br>Executed ' + (df['pop']).astype(str) + " inmates"
limits = [(0,1),(2,8),(9,13)]
limit_names = ['> 10', '2-10', '1']
colors = ["royalblue","crimson","lightseagreen","orange","lightgrey"]
cities = []
scale = 0.01

fig = go.Figure()

for i in range(len(limits)):
    lim = limits[i]
    df_sub = df[lim[0]:lim[1]]
    fig.add_trace(go.Scattergeo(
        locationmode = 'USA-states',
        lon = df_sub['lon'],
        lat = df_sub['lat'],
        text = df_sub['text'],
        marker = dict(
            size = df_sub['pop']/scale,
            color = colors[i],
            line_color='rgb(40,40,40)',
            line_width=0.5,
            sizemode = 'area'
        ),
        name = limit_names[i] ))

fig.update_layout(
        title_text = '2011 Executions by State<br>(Click legend to toggle traces)',
        showlegend = True,
        geo = dict(
            scope = 'usa',
            landcolor = 'rgb(217, 217, 217)',
        )
    )

fig.show()
In [ ]: