def write_plot(clade_storage, other_storage, output_file_name):
			""" wrapper that creates a plot from a storage variable """

			index = ["Clade", "Other"]
			data = [clade_storage, other_storage]
			df = pd.DataFrame(data, index=index)

			grouped_bar = vincent.GroupedBar(df)
			grouped_bar.axis_titles(x='Groups', y='Proportion')
			grouped_bar.legend(title="Legend")
			grouped_bar.to_json(output_file_name)
Пример #2
0
def api_impostos():
    import pandas as pd

    farm_1 = {
        'apples': 10,
        'berries': 32,
        'squash': 21,
        'melons': 13,
        'corn': 18
    }
    farm_2 = {
        'apples': 15,
        'berries': 43,
        'squash': 17,
        'melons': 10,
        'corn': 22
    }
    farm_3 = {
        'apples': 6,
        'berries': 24,
        'squash': 22,
        'melons': 16,
        'corn': 30
    }
    farm_4 = {
        'apples': 12,
        'berries': 30,
        'squash': 15,
        'melons': 9,
        'corn': 15
    }

    farm_data = [farm_1, farm_2, farm_3, farm_4]
    farm_index = ['Farm 1', 'Farm 2', 'Farm 3', 'Farm 4']
    df_farm = pd.DataFrame(farm_data, index=farm_index)

    group = vincent.GroupedBar(df_farm)
    group.axis_titles(x='Total Produce', y='Farms')
    group.legend(title='Produce Types')
    group.colors(brew='Set1')
    return group.to_json()
Пример #3
0
def plot_bar_graphs(df_years, html_link, name, color):
    print('>plotting map...')
    listOfMedians = prepare_for_data(df_years)
    barGraphMap = Map(location = latlng, zoom_start = 10, tiles = 'Stamen Terrain')
    for x,y,df,file,station,ttip in zip(coords['Lat_DD'], coords['Long_DD'], listOfMedians, file_names, coords['Station Number'], coords['Station label']):
        bar = vincent.GroupedBar(df)
        bar.axis_titles(x = "Index", y = name)
        bar.width = 900
        bar.height = 250
        bar.legend(title='Year')
        bar.to_json(file)
        vis1 = os.path.join('/Users/fetch/Desktop/ProjectDirectory', file)
        folium.Marker(location=[x,y], 
                      icon = DivIcon(
            icon_size=(28,25),
            icon_anchor=(7, 20),
            html='<div style="font-family: Rockwell; font-size: 9pt; color :#00664b">'+str(station)+'</div>',
            ),
                      popup=folium.Popup(max_width=1100).add_child(
                              folium.Vega(json.load(open(vis1)), width= 1000, height=300))
                      ).add_to(barGraphMap)
        barGraphMap.add_child(folium.CircleMarker([x,y], fill_color = color, color = color, radius = 22, tooltip = ttip))
    
        barGraphMap.save(html_link+'.html')
Пример #4
0
stack = vincent.StackedBar(df_2)
stack.legend(title='Categories')
stack.scales['x'].padding = 0.1
stack.display()

# <codecell>

stack = vincent.StackedBar(df_farm.T)
stack.axis_titles(x='Total Produce', y='Farms')
stack.legend(title='Produce Types')
stack.colors(brew='Pastel1')
stack.display()

# <codecell>

group = vincent.GroupedBar(df_2)
group.legend(title='Categories')
group.colors(brew='Spectral')
group.width=750
group.display()

# <codecell>

group = vincent.GroupedBar(df_farm)
group.axis_titles(x='Total Produce', y='Farms')
group.legend(title='Produce Types')
group.colors(brew='Set2')
group.display()

# <codecell>
Пример #5
0
g_mteps.to_json('_g_mteps.json', html_out=True, html_path='g_mteps.html')

## Grouped bar graph
## DataFrame needs to be: rows: groups (dataset)
##                        cols: measurements (m_teps, but labeled by categories)
## Each row is a set of measurements grouped together (here, by dataset)
## Each column is an individual measurement (here, mteps)
##
## The pivot changes
##               columns  values
##  [[dataset 1, expt. A, measurement A]]
##  [[dataset 1, expt. B, measurement B]]
## to
##  [[dataset 1, measurement A, measurement B]]

g_grouped = vincent.GroupedBar(
    df.pivot(index='dataset', columns='parameters', values='m_teps'))
g_grouped.axis_titles(x='Dataset', y='MTEPS')
g_grouped.legend(title='Parameters')
g_grouped.colors(brew='Spectral')
# g_grouped.scales['y'].type = 'log'
g_grouped.to_json('_g_grouped.json', html_out=True, html_path='g_grouped.html')

## OK, let's slurp up the Gunrock paper's BFS data for non-Gunrock engines

## unfortunately gunrock-paper is a private repo, so this doesn't work
datasets = list(df.index)
# dfx = pandas.read_excel("https://github.com/owensgroup/gunrock-paper/raw/master/spread_sheets/comparison.xls", 'BFS')
# when reading, use the dataset names as the index. .T is "transpose"
dfx = pandas.read_excel("comparison.xls", 'BFS', index_col=0).T
dfx.index.name = 'dataset'
# get rid of columns (axis = 1) we don't care about
Пример #6
0
    hours = OrderedDict(Counter(hours))
    v = vincent.Bar(hours)
    v.colors(brew='Set1')
    v.axis_titles(x='Day of the Week',y='Number of Tweets')
    fn = str(c)
    v.to_json('day'+fn+'.json',True,'day'+fn+'.html')
    map1.simple_marker(loc,popup=(v,'day'+fn+'.json'))
    c+=1

map1.create_map('boro_dow_map.html')


poly = fiona.open('D:\data\open_toronto\NEIGHBORHOODS_WGS84.shp')
map1 = folium.Map([43.5,-79.37],width=1250,height=600,tiles='Stamen Toner')

c = 0
for rex in poly:
    p = geometry.shape(rex['geometry'])
    loc = [p.centroid.coords.xy[1][0],p.centroid.coords.xy[0][0]]
    hours = [{'day':h.isoweekday(),'hour':h.hour} for h in boros[rex['properties']['AREA_NAME']]['times']]
    #hours = OrderedDict(Counter(hours))
    v = vincent.GroupedBar(pd.DataFrame(hours))
    v.colors(brew='Set2')
    v.axis_titles(x='Time of Day',y='Number of Tweets')
    fn = str(c)
    v.to_json('dowhr'+fn+'.json',True,'dowhr'+fn+'.html')
    map1.simple_marker(loc,popup=(v,'dowhr'+fn+'.json'))
    c+=1

map1.create_map('boro_dowhr_map.html')