Concept: What is the distribution of IMLS grants, and what do these grants do?
Your second dataset will be the IMLS discretionary grants database. These grants include information about the topic of the grant, the institution that received it, its duration, and a few other pieces of data. You may also find useful and interesting data (especially related to zip codes and economic factors) at FRED.
Your visualization should be interactive. There are several frameworks you can use to do this. The three that we have discussed in detail in class have been using the IPython widgets interface to build small, exploratory visualizations, the Bokeh framework and Plotly. You may not use Tableau to build this visualization. If there is another framework you would like to use, please ask.
A few of the concepts that you may explore:
What types of grants are supported by IMLS?
How are these grants distributed across the United States? Are they particularly clustered in certain states?
Is there a relationship between the economic factors in a zip code and the grants from IMLS?
Generate from this data either a notebook that can be executed, a python script that can be executed, or a plotly dashboard that can be accessed. If you utilize plotly, at lease some of the plotly setup must be in a python script.
In [1]:
#import packages
%matplotlib inline
import matplotlib.pyplot as plt
import csv
import numpy as np
import pandas as pd
import collections
import plotly
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.graph_objs import *
plotly.tools.set_credentials_file(username='alexbear', api_key='L6m9DmfDjqrksfHtUH5j')
#plotly.tools.set_credentials_file(username='jlwang233', api_key='hBFucEx4GrL7V9xxFhx0')
#plotly.tools.set_credentials_file(username='lis590dv', api_key='0jCaIttf2QaVJ3lRZZlK')
#plotly.tools.set_credentials_file(username='jxljiang221', api_key='RgXxTYxCam4vBca8DHDq')
#plotly.tools.set_credentials_file(username='jxljiang221', api_key='LOONcFbgZszSxdiuB3Kn')
In [16]:
#Q2-1 BY YINGJUN GUAN
plt.rcParams["figure.figsize"] = (15, 8)
df2 = pd.read_csv("DiscGrants96to13.csv",encoding='iso-8859-1')
cc=collections.Counter(df2["ProgramType"])
vv=[]
kk=[]
for v,k in sorted(cc.items(), key=lambda i: i[1], reverse=True):
vv.append(v)
kk.append(k)
objects = vv
y_pos = np.arange(len(objects))
performance = kk
plt.bar(y_pos, performance, align='center', alpha=0.5)
plt.xticks(y_pos, objects)
plt.ylabel('Number of grants')
plt.xlabel('Type of programs')
plt.title('Program types vs their counts')
plt.show()
In [3]:
sum(performance)
Out[3]:
In [4]:
performance
Out[4]:
Q2-1
We firstly study the distribution of program types. From the histogram we can see that LG(National Leadership Grants) contributes to the most count of grants, 3741, which is 28.3% of total grants. IL(Museum Leadership Initiatives) and LE(Native American Enhancement Grants) has the least number of grants, 57 and 51 respectively.
In [5]:
df2.head()
Out[5]:
In [6]:
df3=df2[(df2["Longitude"]>-95)&(df2["Latitude"]<24)]
#df2=df2[(((df2["Longitude"]>-95)&(df2["Latitude"]<24))==False)]
df2=df2[((df2["InstState"]=="GU")|(df2["InstState"]=="PW")|(df2["InstState"]=="VI")|(df2["InstState"]=="PR")|(df2["InstState"]=="MP")|(df2["InstState"]=="FM")|(df2["InstState"]=="MH")|(df2["InstState"]=="AS")|(df2["InstState"]==""))==False]
In [7]:
df2.describe
Out[7]:
In [8]:
#Q2-2a BY XINYU ZHANG
yearly=[]
state=[]
for year,group in df2.groupby('FiscalYear'):
print (year)
df_2=group.groupby('InstState')
# state=df4['InstState'].unique()
state.append(df_2.groups)
total=df_2['AwardTotal'].sum()
print(total)
yearly.append(total)
#print(yearly[0])
In [29]:
scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],[0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]
df5=df2.groupby('FiscalYear').get_group(1996)
df4=df5.groupby('InstState')
#df5=df4.get_group
state=[]
amount=[]
for name,group in df4:
state.append(str(name))
amount.append(str(group['AwardTotal'].sum()))
# state=df4['InstState'].unique()
# state.append(df4.groups)
location = pd.DataFrame(state,columns = ['state'])
total= pd.DataFrame(amount,columns = ['amount'])
# yearly.append(total)
# for i in range(3):
data = [ dict(
type='choropleth',
colorscale = scl,
# autocolorscale = False,
# locations=df['InstState'].unique(),
# locations=state[i],
# z = yearly[i],
locations = location['state'],
z = total['amount'],
# df4['text'] = 'State: ' + df4.groups+ '<br>Total Amount: '+ z + ' dollar',
text = 'State: ' + location['state'] + '<br>Total Amount: '+ total['amount'] + ' dollar',
locationmode = 'USA-states',
marker = dict(
line = dict (
color = 'rgb(255,255,255)',
width = 2
) ),
colorbar = dict(
title = "Millions USD")
) ]
layout = dict(
#title = str(1996+i)+'US Administrative Discretionary Grants<br>(Hover for breakdown)',
title = '1996 US Administrative Discretionary Grants<br>(Hover for breakdown)',
geo = dict(
scope='usa',
projection=dict( type='albers usa' ),
showlakes = True,
lakecolor = 'rgb(255, 255, 255)'),
)
fig = dict( data=data, layout=layout )
py.plotly.iplot( fig)
#break
#py.iplot(fig)
Out[29]:
In [30]:
scl = [[0.0, 'rgb(242,240,247)'],[0.2, 'rgb(218,218,235)'],[0.4, 'rgb(188,189,220)'],[0.6, 'rgb(158,154,200)'],[0.8, 'rgb(117,107,177)'],[1.0, 'rgb(84,39,143)']]
df5=df2.groupby('FiscalYear').get_group(2013)
df4=df5.groupby('InstState')
#df5=df4.get_group
state=[]
amount=[]
for name,group in df4:
state.append(str(name))
amount.append(str(group['AwardTotal'].sum()))
# state=df4['InstState'].unique()
# state.append(df4.groups)
location = pd.DataFrame(state,columns = ['state'])
total= pd.DataFrame(amount,columns = ['amount'])
# yearly.append(total)
# for i in range(3):
data = [ dict(
type='choropleth',
colorscale = scl,
# autocolorscale = False,
# locations=df['InstState'].unique(),
# locations=state[i],
# z = yearly[i],
locations = location['state'],
z = total['amount'],
# df4['text'] = 'State: ' + df4.groups+ '<br>Total Amount: '+ z + ' dollar',
text = 'State: ' + location['state'] + '<br>Total Amount: '+ total['amount'] + ' dollar',
locationmode = 'USA-states',
marker = dict(
line = dict (
color = 'rgb(255,255,255)',
width = 2
) ),
colorbar = dict(
title = "Millions USD")
) ]
layout = dict(
#title = str(1996+i)+'US Administrative Discretionary Grants<br>(Hover for breakdown)',
title = '2013 US Administrative Discretionary Grants<br>(Hover for breakdown)',
geo = dict(
scope='usa',
projection=dict( type='albers usa' ),
showlakes = True,
lakecolor = 'rgb(255, 255, 255)'),
)
fig = dict( data=data, layout=layout )
py.plotly.iplot( fig)
#break
#py.iplot(fig)
Out[30]:
Q2-2a We make heatmap on 1996 and 2013 total grant amount by 51 states and also the DC region. For the convenience of plotting, region with the abbreviation 'GU','PW','VI','MP','FM','MH''AS','PR' are omitted. The state with deeper color was entitled with larger amount. Here we find some variations on the amount and whether the state was granted. For instance, the maximum grants increased from 2 million up to 7 million. Another example is that California topped the granted amount in 1996 but was only amoung the middle in 2013. There are also states who wasn't granted during these seven years.
In [20]:
#Q2-2b BY XIAOLIANG JIANG
df2['Text'] = df2['Institution'] + '<br>' + df2['Program'] + '<br>' + 'Program Type: ' + df2['ProgramType'] + '<br>' + 'Total Award: ' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
#df2['text'] = df2['Institution'] + 'Total Award' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
limits = [(0,10),(10,100),(100,200),(200,500),(500,1000),(1000,3000)]
#colors = ["#ffcccc","#ffddcc","#ffeecc","#ffffcc","#eeffcc","#ddffcc"]
colors = ["e0e0e0","#66b2ff","#66ff66","#ffff66","#ffb266","#ff6666"]
institutions = []
scale = 6000
for i in range(len(limits)):
subdf2=df2[((df2['AwardTotal']/1e3)<limits[i][1])&((df2['AwardTotal']/1e3)>limits[i][0])]
institution = dict(
type = 'scattergeo',
locationmode = 'USA-states',
lon = subdf2['Longitude'],
lat = subdf2['Latitude'],
text = subdf2['Text'],
marker = dict(
size = subdf2['AwardTotal']/scale,
color = colors[i],
line = dict(width=0.5, color='rgb(40,40,40)'),
sizemode = 'area'
),
name ='{0} - {1}'.format(limits[i][0],limits[i][1])+' thousand dollar' )
institutions.append(institution)
In [21]:
layout = dict(
title = 'Administrative Discretionary Grants<br>(Click legend to toggle traces)',
showlegend = True,
geo = dict(
scope='usa',
projection=dict( type='albers usa' ),
showland = True,
landcolor = 'rgb(217, 217, 217)',
subunitwidth=1,
countrywidth=1,
subunitcolor="rgb(255, 255, 255)",
countrycolor="rgb(255, 255, 255)"
),
updatemenus=list([
dict(
x=-0.05,
y=1,
yanchor='top',
buttons=list([
dict(
args=['visible', [True, True, True, True, True, True]],
label='All',
method='restyle'
),
dict(
args=['visible', [True, False, False, False, False, False]],
label='0-10 thousand dollar',
method='restyle'
),
dict(
args=['visible', [False, True, False, False, False, False]],
label='10-100 thousand dollar',
method='restyle'
),
dict(
args=['visible', [False, False, True, False, False, False]],
label='100-200 thousand dollar',
method='restyle'
),
dict(
args=['visible', [False, False, False, True, False, False]],
label='200-500 thousand dollar',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, True, False]],
label='500-1000 thousand dollar',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, True]],
label='1000+ thousand dollar',
method='restyle'
)
]),
)
]),
)
fig = dict( data=institutions, layout=layout )
py.iplot( fig, validate=False, filename='q2testworldmap' )
Out[21]:
The map above is classified by project sized in different locations. There are 18 missing values and we add them mannually by looking for the address on the Google Map and record each instance's longitude and latitute. With the interactive map, you can view a single project amount class by double click on the color spot in front of the tag and hide the colorful spots by single click the spot before the item tag.
Summary: 0-10: large counts, nationwide, concentrated on east and west coasts 10-100: less counts, nationwide, concentrated on east and west coasts 100-200: less counts, nationwide, concentrated on east coast 200-500: less counts, nationwide, concentrated on east coast 500-1000: small countss, not so many in the middle, concentrated on east coast 1000-3000: only several counts, only at Chicago and NY and Boston.
In [38]:
df2['Text'] = df2['Institution'] + '<br>' + df2['Program'] + '<br>' + 'Program Type: ' + df2['ProgramType'] + '<br>' + 'Total Award: ' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
#df2['text'] = df2['Institution'] + 'Total Award' + (df2['AwardTotal']/1e3).astype(str)+ ' thousand'
#limits = [(0,10),(10,100),(100,200),(200,500),(500,1000),(1000,3000)]
#colors = ["#ffcccc","#ffddcc","#ffeecc","#ffffcc","#eeffcc","#ddffcc"]
colors = ["#ff6666","#ffb266","#ffff66","#b2ff66","#66ff66","#66ffb2","#66ffff","#66b2ff","#6666ff","#ff66ff","#b266ff","#ff66b2","#000000","#404040","#808080","#c0c0c0","#ffffff"]
pt=["IL","ST","ML","RE","IC","IM","IS","MN","LE","MP","MH","LT","LI","IG","MA","IA","IG"]
institutions = []
scale = 5000
for i in range(len(colors)):
subdf2=df2[df2["ProgramType"]==pt[16-i]]
institution = dict(
type = 'scattergeo',
locationmode = 'USA-states',
lon = subdf2['Longitude'],
lat = subdf2['Latitude'],
text = subdf2['Text'],
marker = dict(
size = subdf2['AwardTotal']/scale,
color = colors[16-i],
line = dict(width=0.5, color='rgb(40,40,40)'),
sizemode = 'area'
),
name =pt[i])
institutions.append(institution)
layout = dict(
title = 'Administrative Discretionary Grants<br>(Click legend to toggle traces)',
showlegend = True,
geo = dict(
scope='usa',
projection=dict( type='albers usa' ),
showland = True,
landcolor = 'rgb(217, 217, 217)',
subunitwidth=1,
countrywidth=1,
subunitcolor="rgb(255, 255, 255)",
countrycolor="rgb(255, 255, 255)"
)
)
fig = dict( data=institutions, layout=layout )
py.iplot( fig, validate=False, filename='q2testworldmap' )
Out[38]:
This interactive graph shows the geographic distribution of grant types in the United States. The size of spots on the map represents the amount of the grant. We can tell from the figure that certain grant types such as MN, IA and LE have less number of grants than others and are distibuted more evenly around the country. Grant types such as IG are mostly distributed along the east and west coast lines.
Summary:
IL, ML, RE: small amounts, large grant counts, nationwide but concentrated on northeastern. ST: smaller amounts, large counts, nationwide but concentrated on northeastern IC, IM: smaller amounts, small counts, nationwide but are less in mid and eastern, more concentrated on ALASKA IS,MA: small amounts, small counts, more concentrated on eastern MN,IA: large amounts, small counts, more concentrated along coast lines LE: small amounts, smaller counts, nationwide but less on eastern MP: smaller amounts, mid counts, nationwide but less on eastern NH,LI: smaller amounts, mid counts, nationwide but concentrated on eastern LT: smaller amounts, larger counte, nationwide IG: larger amounts, mid counts, nationwide, concentrated on eastern
In [36]:
#Q2-3 BY JIALU WANG
fn1 = "amt.csv"
with open(fn1, "r") as f:
reader1 = csv.reader(f)
header1 = next(reader1)
data1 = {}
for column1 in header1:
data1[column1] = []
for row1 in reader1:
for column1, value1 in zip(header1, row1):
data1[column1].append(value1)
fn2 = "GeoFRED_Total_Gross_Domestic_Product_by_State_Millions_of_Dollars.csv"
with open(fn2, "r") as f:
reader2 = csv.reader(f)
header2 = next(reader2)
data2 = {}
for column2 in header2:
data2[column2] = []
for row2 in reader2:
for column2, value2 in zip(header2, row2):
data2[column2].append(value2)
In [37]:
plt.rcParams["figure.figsize"] = (40, 20)
states =data2['InstState']
AWT1997=data1['1997']
GDP1997=data2['1997']
AWT1998=data1['1998']
GDP1998=data2['1998']
AWT1999=data1['1999']
GDP1999=data2['1999']
AWT2000=data1['2000']
GDP2000=data2['2000']
AWT2001=data1['2001']
GDP2001=data2['2001']
AWT2002=data1['2002']
GDP2002=data2['2002']
AWT2003=data1['2003']
GDP2003=data2['2003']
AWT2004=data1['2004']
GDP2004=data2['2004']
AWT2005=data1['2005']
GDP2005=data2['2005']
AWT2006=data1['2006']
GDP2006=data2['2006']
AWT2007=data1['2007']
GDP2007=data2['2007']
AWT2008=data1['2008']
GDP2008=data2['2008']
AWT2009=data1['2009']
GDP2009=data2['2009']
AWT2010=data1['2010']
GDP2010=data2['2010']
AWT2011=data1['2011']
GDP2011=data2['2011']
AWT2012=data1['2012']
GDP2012=data2['2012']
AWT2013=data1['2013']
GDP2013=data2['2013']
trace11 = go.Scatter(
x = states,
y = AWT1997,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace12 = go.Scatter(
x = states,
y = GDP1997,
mode = 'lines+markers',
name = 'GDP'
)
trace21 = go.Scatter(
x = states,
y = AWT1998,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace22 = go.Scatter(
x = states,
y = GDP1998,
mode = 'lines+markers',
name = 'GDP'
)
trace31 = go.Scatter(
x = states,
y = AWT1999,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace32 = go.Scatter(
x = states,
y = GDP1999,
mode = 'lines+markers',
name = 'GDP'
)
trace41 = go.Scatter(
x = states,
y = AWT2000,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace42 = go.Scatter(
x = states,
y = GDP2000,
mode = 'lines+markers',
name = 'GDP'
)
trace51 = go.Scatter(
x = states,
y = AWT2001,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace52 = go.Scatter(
x = states,
y = GDP2001,
mode = 'lines+markers',
name = 'GDP'
)
trace61 = go.Scatter(
x = states,
y = AWT2002,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace62 = go.Scatter(
x = states,
y = GDP2002,
mode = 'lines+markers',
name = 'GDP'
)
trace71 = go.Scatter(
x = states,
y = AWT2003,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace72 = go.Scatter(
x = states,
y = GDP2003,
mode = 'lines+markers',
name = 'GDP'
)
trace81 = go.Scatter(
x = states,
y = AWT2004,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace82 = go.Scatter(
x = states,
y = GDP2004,
mode = 'lines+markers',
name = 'GDP'
)
trace91 = go.Scatter(
x = states,
y = AWT2005,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace92 = go.Scatter(
x = states,
y = GDP2005,
mode = 'lines+markers',
name = 'GDP'
)
trace101 = go.Scatter(
x = states,
y = AWT2006,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace102 = go.Scatter(
x = states,
y = GDP2006,
mode = 'lines+markers',
name = 'GDP'
)
trace111 = go.Scatter(
x = states,
y = AWT2007,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace112 = go.Scatter(
x = states,
y = GDP2007,
mode = 'lines+markers',
name = 'GDP'
)
trace121 = go.Scatter(
x = states,
y = AWT2008,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace122 = go.Scatter(
x = states,
y = GDP2008,
mode = 'lines+markers',
name = 'GDP'
)
trace131 = go.Scatter(
x = states,
y = AWT2009,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace132 = go.Scatter(
x = states,
y = GDP2009,
mode = 'lines+markers',
name = 'GDP'
)
trace141 = go.Scatter(
x = states,
y = AWT2010,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace142 = go.Scatter(
x = states,
y = GDP2010,
mode = 'lines+markers',
name = 'GDP'
)
trace151 = go.Scatter(
x = states,
y = AWT2011,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace152 = go.Scatter(
x = states,
y = GDP2011,
mode = 'lines+markers',
name = 'GDP'
)
trace161 = go.Scatter(
x = states,
y = AWT2012,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace162 = go.Scatter(
x = states,
y = GDP2012,
mode = 'lines+markers',
name = 'GDP'
)
trace171 = go.Scatter(
x = states,
y = AWT2013,
mode = 'lines+markers',
name = 'Awarded Amount'
)
trace172 = go.Scatter(
x = states,
y = GDP2013,
mode = 'lines+markers',
name = 'GDP'
)
mydata = [trace11,trace12,trace21,trace22,trace31,trace32,trace41,trace42,
trace51,trace52,trace61,trace62,trace71,trace72,trace81,trace82,
trace91,trace92,trace101,trace102,trace111,trace112,trace121,trace122,
trace131,trace132,trace141,trace142,trace151,trace152,trace161,trace162,
trace171,trace172]
layout = Layout(
title='Total State Amount vs GDP by State Per Year',
updatemenus=list([
dict(
x=-0.05,
y=1,
yanchor='top',
buttons=list([
dict(
args=['visible', [True,True, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='1997',
method='restyle'
),
dict(
args=['visible', [False, False, True,True,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='1998',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, True,True,False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='1999',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,True,True,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2000',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
True,True,False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2001',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,True,True,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2002',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, True,True,False, False,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2003',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,True,True,
False, False, False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2004',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
True,True,False, False,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2005',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,True,True,False, False, False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2006',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, True,True,False, False,
False, False, False, False,False, False, False, False,
False, False]],
label='2007',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,True,True,
False, False, False, False,False, False, False, False,
False, False]],
label='2008',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
True,True,False, False,False, False, False, False,
False, False]],
label='2009',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,True,True,False, False, False, False,
False, False]],
label='2010',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, True,True,False, False,
False, False]],
label='2011',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,True,True,
False, False]],
label='2012',
method='restyle'
),
dict(
args=['visible', [False, False, False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
False, False,False, False, False, False,False, False,
True,True]],
label='2013',
method='restyle'
),
]),
)
]),
)
fig = Figure(data=mydata, layout=layout)
py.iplot(fig)
Out[37]:
Q2-3 The graph is a comparison between total awarded amount by state and GDP by state, as an indicator for the economic environment.The dropdown menu is the year of the statistics. From each year's line chart, we can see that states with higher GDP generally has higher amount of grants. For instance, CA, FL, PA, TX, NM has higher GDP compared to other states and they are also entitled with higher grant amount. However, there are also some states such as IL and NY with low GDP but high grant amount. We guess that there might be special study programs promoted by the government to support local library and museum development.It can also be observed that with the steady increasement of GDP year by year, the grant amount also sees a general increasing trend.