コード例 #1
0
ファイル: graphs.py プロジェクト: JWPatt/SBB
def get_mapbox_graph(sbb, hovertext_cols, options_list, option_dropdown, colorbar, travel_time_cols,
                     dropdown_locations=None):
    cmin = min(colorbar[option_dropdown]['intervals'])*3600
    cmax = max(colorbar[option_dropdown]['intervals'])*3600

    mapbox_graph = [Scattermapbox(
        lat=sbb["lat"],
        lon=sbb["lon"],
        mode="markers",
        hoverinfo='text',
        hovertext=sbb[hovertext_cols[options_list[option_dropdown]]],
        text=sbb[hovertext_cols[options_list[option_dropdown]]],
        marker=dict(
            showscale=True,
            color=sbb[travel_time_cols[options_list[option_dropdown]]],
            opacity=0.85,
            size=7.5,
            colorscale=colorbar[option_dropdown]['input'],
            cmax=cmax,
            cmin=cmin,
            colorbar=dict(
                title=colorbar[option_dropdown]['title'],
                x=0.035,
                xpad=0,
                tickvals=colorbar[option_dropdown]['tickvals'],
                ticktext=colorbar[option_dropdown]['ticktext'],
                tickfont=dict(color="#000000",
                              size=14),
                titlefont=dict(color="#000000",
                               size=16),
                ticksuffix=" hours",
                showticksuffix="all",
                thicknessmode="pixels",
            ),
        ),
    )]
    if dropdown_locations:
        mapbox_graph.append(
            # Plot of important locations on the map
            Scattermapbox(
                lat=[dropdown_locations[i]["lat"] for i in dropdown_locations],
                lon=[dropdown_locations[i]["lon"] for i in dropdown_locations],
                mode="markers",
                hoverinfo="text",
                text=[i for i in dropdown_locations],
                marker=dict(size=8, color="#000000"),
            )
        )

    return mapbox_graph
コード例 #2
0
def plotly_map(locations):
    mapbox_access_token = 'pk.eyJ1Ijoic3VodHdpbnMiLCJhIjoi' +\
                        'Y2pnNGJvbXRhMGpoNDJwcWRva3JieWgwcCJ9' +\
                        '.cmsuwG65XkGUh2pv07nIVg'

    data = [
        Scattermapbox(
            lat=[location.latitude for location in locations],
            lon=[location.longitude for location in locations],
            text=[location.name for location in locations],
            mode='markers',
        )
    ]

    layout = Layout(
        autosize=True,
        hovermode='closest',
        mapbox=dict(
            accesstoken=mapbox_access_token,
            bearing=0,
            center=dict(
                lat=mean([location.latitude for location in locations]),
                lon=mean([location.longitude for location in locations])),
            pitch=100,
            zoom=10),
    )

    fig = dict(data=data, layout=layout)
    output = plotly.offline.plot(fig,
                                 include_plotlyjs=False,
                                 output_type='div')
    return (output)
コード例 #3
0
def plot_map(restos, cuisine_type='Thai'):
    """ Visualise restaurants on a map of NYC

        Parameters
        ----------
        restos: DataFrame
            contains NYC restaurant inspection results
        cuisine_type: str
            type of cuisine to search for

        Returns
        -------
        fig : plotly.Figure
    """
    top_ten = get_top_N(restos, cuisine_type=cuisine_type)
    lat_lons = find_lat_lon(top_ten)

    nyc_central_lat = 40.7128
    nyc_central_lon = -73.9

    data = [
        Scattermapbox(
            lon=[lat_lon['lon'] for lat_lon in lat_lons.values],
            lat=[lat_lon['lat'] for lat_lon in lat_lons.values],
            text=[lat_lon['name'] for lat_lon in lat_lons.values],
            mode='markers+text',
            showlegend=False,
            hoverinfo='text',
            textposition='top center',
            marker=dict(symbol='star', size=10),
        )
    ]

    layers = [
        dict(sourcetype='geojson', type='fill', color='rgba(163,22,19,0.8)')
    ]

    layout = Layout(
        title='',
        height=800,
        width=600,
        autosize=True,
        hovermode='closest',
        mapbox=dict(layers=layers,
                    accesstoken=MAPBOX_ACCESS_TOKEN,
                    bearing=0,
                    center=dict(lat=nyc_central_lat, lon=nyc_central_lon),
                    pitch=0,
                    zoom=10,
                    style='light'),
    )

    fig = Figure(layout=layout, data=data)
    iplot(fig, validate=False)

    return fig
コード例 #4
0
def update_graph_user(user):
    zoom = 12.0
    latInitial = 37.766083
    lonInitial = -122.448649
    bearing = 0
  
    venue_list = session.execute("select venue_id, user_id, lat, log, rating  from friendratingloc WHERE user_id = \'{}\'".format(user))
    venue_name = []
    venue_lat = []
    venue_lon = []
    venue_rating = []
    for venue in venue_list:
        venue_name.append(venue.venue_id)
        venue_lat.append(venue.lat)
        venue_lon.append(venue.log)
	venue_rating.append(venue.rating)

    return go.Figure(
        data=[
            Scattermapbox(
                #lat=["37.752443", "37.807771", "37.810088", "37.769361", "37.802067"],
                #lon=["-122.447543", "-122.473899", "-122.410428", "-122.485742",
                #     "-122.418840"],
                lat = venue_lat,
		lon = venue_lon,
		mode='markers',
                hoverinfo="text",
                text = venue_rating,
 		#text=["1", "2", "3", "4", "5"],
                # opacity=0.5,
                marker=dict(
                    size=12,
                    color=venue_rating
                ),
            ),
        ],
        layout=Layout(
            autosize=True,
            height=750,
            margin=Margin(l=0, r=0, t=0, b=0),
            showlegend=False,
            mapbox=dict(
                accesstoken=mapbox_access_token,
                 center=dict(
                     lat=latInitial, # 40.7272
                     lon=lonInitial # -73.991251
                 ),
                style='dark',
                bearing=bearing,
                zoom=zoom
            )
        )
    )
コード例 #5
0
def makeborder3(name, lats, lons, color, shape, group, showlegend):
    return Scattermapbox(
        name=name,
        mode="markers",
        lon=lats,
        lat=lons,

        # SPECS
        marker=dict(
            size=15,
            color=color,
            symbol=shape,
            opacity=0.8,
        ),
        legendgroup=group,
        showlegend=showlegend,
    )
コード例 #6
0
def maketrace(name, lats, lons, dataframe, color, shape, group, showlegend,
              sd):
    return Scattermapbox(
        name=name,
        mode="markers",
        lon=lats,
        lat=lons,
        text="ID: " + dataframe['ID'].astype(str) +
        "<br>Mask/Social Distance Compliance: " + sd,
        hoverinfo="lon+lat+text",
        # SPECS
        marker=dict(
            size=12,
            color=color,
            symbol=shape,
            opacity=0.8,
        ),
        legendgroup=group,
        showlegend=showlegend,
    )
コード例 #7
0
def plot_cluster(days, param="End", peak="AM", marker_size_scale=30):
    config_plotly()

    color_scale = colorlover.scales['5']['qual']['Set1']

    data = list()
    top_size = days['7'].max()
    for cluster in days.cluster_id.unique():
        data.append(
            Scattermapbox(
                lat=days[days.cluster_id == cluster][param + "_Lat_mean" +
                                                     peak],
                lon=days[days.cluster_id == cluster][param + "_Lon_mean" +
                                                     peak],
                mode='markers',
                marker=Marker(size=days[days.cluster_id == cluster]['7'] /
                              top_size * marker_size_scale,
                              color=color_scale[cluster]),
                text="CL: " + str(cluster),
                hoverinfo='text'))

    data = Data(data)

    layout = Layout(
        title='Clusters centres of gravity:' + param + peak,
        autosize=True,
        hovermode='closest',
        showlegend=False,
        mapbox=dict(accesstoken=PLOTLY_API_KEY,
                    bearing=0,
                    center=dict(lat=40, lon=-73),
                    pitch=0,
                    zoom=7,
                    style='light'),
    )
    fig = dict(data=data, layout=layout)
    py.plot(fig, filename='Clusters:' + param + peak)
コード例 #8
0
def plot_vectors(days, peak="PM"):
    _scaler = 6
    config_plotly()

    color_scale = colorlover.scales['5']['qual']['Dark2']

    data = list()
    top_size = days['7'].max()
    for index, row in days.iterrows():
        desc = str(index) + " cluster_id" + str(row['cluster_id'])
        data.append(
            Scattermapbox(
                lat=[row["Start_Lat_mean" + peak], row["End_Lat_mean" + peak]],
                lon=[row["Start_Lon_mean" + peak], row["End_Lon_mean" + peak]],
                mode='lines',
                text=desc,
                name=desc,
                opacity=0.7,
                line=Line(width=int(_scaler * row['7'] / top_size),
                          color=color_scale[int(row['cluster_id'])])))

    data = Data(data)

    layout = Layout(
        showlegend=False,
        autosize=True,
        hovermode='closest',
        mapbox=dict(accesstoken=PLOTLY_API_KEY,
                    bearing=0,
                    center=dict(lat=row["Start_Lat_mean" + peak],
                                lon=row["Start_Lon_mean" + peak]),
                    pitch=0,
                    zoom=11),
    )

    fig = dict(data=data, layout=layout)
    py.plot(fig, filename='Vectors ' + peak)
コード例 #9
0
def update_graph(interval):
    zoom = 12.0
    latInitial = 37.766083
    lonInitial = -122.448649
    bearing = 0

    venue_list = session.execute(
        'select venue_id, latitude, longitude,SUM(visit) AS totalvisit from venuevisitloc GROUP BY venue_id LIMIT 500'
    )
    venue_name = []
    venue_visit = []
    venue_lat = []
    venue_lon = []
    for venue in venue_list:
        venue_name.append(venue.venue_id)
        venue_visit.append(venue.totalvisit)
        venue_lat.append(venue.latitude)
        venue_lon.append(venue.longitude)

    # to get fixed color range:
    y = np.array(venue_visit)
    color = np.array(['rgb(255,255,255)'] * y.shape[0])
    for i in range(y.shape[0]):
        if y[i] < 10: color[i] = 'rgb(166,206,227)'
        elif y[i] >= 10 and y[i] < 100: color[i] = 'rgb(31,120,180)'
        elif y[i] >= 100 and y[i] < 200: color[i] = 'rgb(178,223,138)'
        elif y[i] >= 200 and y[i] < 400: color[i] = 'rgb(51,160,44)'
        elif y[i] >= 400 and y[i] < 800: color[i] = 'rgb(251,154,153)'
        else: color[i] = 'rgb(227,26,28)'

    return go.Figure(
        data=[
            Scattermapbox(
                # lat=["37.752443", "37.807771", "37.810088", "37.769361", "37.802067",
                #      "40.7127", "40.7589", "40.8075", "40.7489"],
                # lon=["-122.447543", "-122.473899", "-122.410428", "-122.485742",
                #      "-122.418840", "-74.0134", "-73.9851", "-73.9626",
                #       "-73.9680"],
                lat=venue_lat,
                lon=venue_lon,
                mode='markers',
                hoverinfo="text",
                text=venue_visit,
                #text=["Twin Peaks", "Golden Gate Bridge",
                #      "Pier 39", "Golden Gate Park",
                #      "Lombard Street", "One World Trade Center",
                #      "Times Square", "Columbia University",
                #      "United Nations HQ"],
                # opacity=0.5,
                marker=dict(
                    size=8,
                    #color="#ffa0a0"
                    # color = venue_visit,
                    color=color.tolist(),
                    #		    colorbar=dict(
                    #             	  	title='Colorbar'
                    #         	    ),
                    #	            colorscale = [[0, 'rgb(166,206,227)'], [0.25, 'rgb(31,120,180)'], [0.45, 'rgb(178,223,138)'], [0.65, 'rgb(51,160,44)'], [0.85, 'rgb(251,154,153)'], [1, 'rgb(227,26,28)']],
                    # colorscale='Jet',
                ),
            ),
        ],
        layout=Layout(
            autosize=True,
            height=750,
            margin=Margin(l=0, r=0, t=0, b=0),
            showlegend=False,
            mapbox=dict(
                accesstoken=mapbox_access_token,
                center=dict(
                    lat=latInitial,  # 40.7272
                    lon=lonInitial  # -73.991251
                ),
                style='dark',
                bearing=bearing,
                zoom=zoom)))
コード例 #10
0
def plotly_map():
    mapbox_access_token = 'pk.eyJ1Ijoic3VodHdpbnMiLCJhIjoi' +\
                        'Y2pnNGJvbXRhMGpoNDJwcWRva3JieWgwcCJ9' +\
                        '.cmsuwG65XkGUh2pv07nIVg'

    data = Data([
        Scattermapbox(
            lat=['37.7765', '37.791377'],
            lon=['-122.4506', '-122.392609'],
            mode='markers',
            marker=Marker(size=15),
            text=["University of San Francisco, Main Campus",
                  "University of San Francisco, Downtown Campus"])])
    layout = Layout(
        autosize=True,
        hovermode='closest',
        mapbox=dict(
            accesstoken=mapbox_access_token,
            bearing=0,
            center=dict(
                lat=37.773972,
                lon=-122.431297
            ),
            pitch=0,
            zoom=11
        ),
    )

    fig = dict(data=data, layout=layout)
    output = plotly.offline.plot(fig, include_plotlyjs=False,
                                 output_type='div')

    activities_grouped_df = activities_df.groupby(['date'], as_index=False)['miles'].sum()
    activities_grouped_df['dow'] = activities_grouped_df.date.apply(lambda x: x.weekday())
    activities_grouped_df['week_start'] = activities_grouped_df.date.apply(lambda x: x - timedelta(days=x.weekday()))

    miles_per_week = activities_grouped_df.groupby(['week_start'], as_index=False).miles.sum()
    by_week_df = pd.DataFrame(activities_grouped_df.week_start.unique(), columns=['week_start'])

    for i in range(7):
        by_week_df['{}'.format(i)] = i

    for i in range(7):
        by_week_df = pd.merge(by_week_df, activities_grouped_df, left_on=['week_start', '{}'.format(i)],
                              right_on=['week_start', 'dow'], how='left', suffixes=('', '_{}'.format(i)))

    by_week_df = by_week_df[['week_start', 'miles', 'miles_1', 'miles_2', 'miles_3', 'miles_4', 'miles_5', 'miles_6']]
    by_week_df.columns = ['week_start', 'miles_0', 'miles_1', 'miles_2', 'miles_3', 'miles_4', 'miles_5', 'miles_6']
    by_week_df['year'] = by_week_df['week_start'].apply(lambda x: x.year)
    by_week_df.fillna(0, inplace=True)
    by_week_df = pd.merge(by_week_df, miles_per_week, how='left', on='week_start')

    days_dict = {0: 'Monday', 1: 'Tuesday', 2: 'Wednesday', 3: 'Thursday', 4: 'Friday', 5: 'Saturday', 6: 'Sunday'}

    dimensions = list()

    for i in range(7):
        dimensions.append(
            dict(range=[0, 20],
                 constraintrange=[0, 20],
                 label='{}'.format(days_dict[i]), values=by_week_df['miles_{}'.format(i)]))

    data = [
        go.Parcoords(
            line=dict(color=by_week_df['miles'],
                      colorscale='Hot',
                      showscale=True,
                      reversescale=True),
            opacity=0.5,
            dimensions=dimensions, hoverinfo='text')

    ]

    layout = go.Layout(
        plot_bgcolor='#E5E5E5',
        paper_bgcolor='#E5E5E5',
        title='Miles per week broken down by day'
    )

    fig = go.Figure(data=data, layout=layout)

    output2 = plotly.offline.plot(fig, include_plotlyjs=False,
                                 output_type='div')

    activities_df['week_start'] = activities_df.date.apply(lambda x: x - timedelta(days=x.weekday()))
    activities_grouped_df_2 = activities_df.groupby(['workout_type', 'week_start'], as_index=False)['miles'].sum()

    by_week_activity_df = pd.DataFrame(activities_grouped_df_2.week_start.unique(), columns=['week_start'])

    for i in activities_df.workout_type.unique():
        by_week_activity_df['{}'.format(i)] = i

    for i in range(4):
        by_week_activity_df = pd.merge(by_week_activity_df, activities_grouped_df_2,
                                       left_on=['week_start', '{}'.format(activities_df.workout_type.unique()[i])],
                                       right_on=['week_start', 'workout_type'], how='left',
                                       suffixes=('', '_{}'.format(activities_df.workout_type.unique()[i])))

    by_week_activity_df = by_week_activity_df[['week_start', 'miles', 'miles_Workout', 'miles_Long Run', 'miles_Race']]
    by_week_activity_df.columns = ['week_start', 'miles_Run', 'miles_Workout', 'miles_Long Run', 'miles_Race']
    by_week_activity_df.fillna(0, inplace=True)

    by_week_activity_df['miles_Run'] = np.array(by_week_activity_df['miles_Run']) + np.array(
        by_week_activity_df['miles_Long Run'])

    by_week_activity_df['miles_Run'] = np.array(by_week_activity_df['miles_Run']) + np.array(
        by_week_activity_df['miles_Long Run'])

    data = []
    custom_colours = ['blue', 'orange', 'red']
    j = 0
    for i in ['Run', 'Workout', 'Race']:
        data.append(go.Bar(
            x=by_week_activity_df['week_start'],
            y=by_week_activity_df['miles_{}'.format(i)],
            marker=dict(color=custom_colours[j]),
            name=i))
        j += 1

    layout = dict(
        barmode='stack',
        hovermode='closest',
        title='Miles per week',
        xaxis=dict(
            rangeselector=dict(
                buttons=list([
                    dict(count=1,
                         label='1m',
                         step='month',
                         stepmode='backward'),
                    dict(count=6,
                         label='6m',
                         step='month',
                         stepmode='backward'),
                    dict(count=1,
                         label='YTD',
                         step='year',
                         stepmode='todate'),
                    dict(count=1,
                         label='1y',
                         step='year',
                         stepmode='backward'),
                    dict(step='all')
                ])
            ),
            rangeslider=dict(),
            type='date'
        )
    )

    fig = go.Figure(data=data, layout=layout)

    output3 = plotly.offline.plot(fig, include_plotlyjs=False,
                                 output_type='div')

    return(output,output2,output3)
コード例 #11
0
    def st_map(self,
               zoom=11,
               style='mapbox://styles/rmetfc/ck1manozn0edb1dpmvtzle2cp',
               build_order=None):
        if self.dataset.node_station_info is None or len(
                self.dataset.node_station_info) == 0:
            raise ValueError('No station information found in dataset')

        import numpy as np
        import plotly
        from plotly.graph_objs import Scattermapbox, Layout

        mapboxAccessToken = "pk.eyJ1Ijoicm1ldGZjIiwiYSI6ImNrMW02YmwxbjAxN24zam9kNGVtMm5raWIifQ.FXKqZCxsFK-dGLLNdeRJHw"

        # os.environ['MAPBOX_API_KEY'] = mapboxAccessToken

        # lat_lng_name_list = [e[2:] for e in self.dataset.node_station_info]
        build_order = build_order or list(
            range(len(self.dataset.node_station_info)))

        color = ['rgb(255, 0, 0)' for _ in build_order]

        lat = np.array([float(e[2]) for e in self.dataset.node_station_info
                        ])[self.traffic_data_index]
        lng = np.array([float(e[3]) for e in self.dataset.node_station_info
                        ])[self.traffic_data_index]
        text = [str(e) for e in range(len(build_order))]

        file_name = self.dataset.dataset + '-' + self.dataset.city + '.html'

        bikeStations = [
            Scattermapbox(
                lon=lng,
                lat=lat,
                text=text,
                mode='markers',
                marker=dict(
                    size=6,
                    #  color=['rgb(%s, %s, %s)' % (255,
                    #                                               195 - e * 195 / max(build_order),
                    #                                               195 - e * 195 / max(build_order)) for e in build_order],
                    color=color,
                    opacity=1,
                ))
        ]

        layout = Layout(
            title=
            'Bike Station Location & The latest built stations with deeper color',
            autosize=True,
            hovermode='closest',
            showlegend=False,
            mapbox=dict(accesstoken=mapboxAccessToken,
                        bearing=0,
                        center=dict(lat=np.median(lat), lon=np.median(lng)),
                        pitch=0,
                        zoom=zoom,
                        style=style),
        )

        fig = dict(data=bikeStations, layout=layout)
        plotly.offline.plot(fig, filename=file_name)
コード例 #12
0
# Dataset: Starbucks Locations in USA
# Data Source: https://gist.github.com/dankohn/09e5446feb4a8faea24f
df = pd.read_csv('/home/local/ALGOANALYTICS/sayali/Desktop/Data Visualisation/Satellite map/starbucks_us_locations.csv')
df.columns = ['Longitude','Latitude','ADR_Line_1','ADR_Line_2']

# Open mapbox account and pass your access token over here
# Mapbox account sign up and access token is free. 
# Mapbox information: https://www.mapbox.com/help/how-access-tokens-work/#rotating-tokens 
mapbox_access_token = 'Enter_your_access_token'
                           
# Use Scattermap box for satellite maps
data = Data([Scattermapbox(
        lat= df['Latitude'],
        lon= df['Longitude'],
        #color = df['MAPE_scaled'],
        text = [str(n) for n in df['ADR_Line_2']],
        mode='markers',
        marker = dict(color = 'rgb(139, 0, 139)',size=11),  
        hoverinfo='skip'
    ) ])    
                      

# Declare Layout    
layout = Layout(
    title = "STARBUCKS LOCATIONS IN USA",
    font=dict(family='Courier New, monospace', size=18, color='rgb(0,0,0)'),
    autosize=False,
    hovermode='closest',
    showlegend=False,
    width=1800,
    height=1000,
コード例 #13
0
    ids.append(pf['id'][i])
    if pf["Masksd"][i] == 1:
        masklon.append(pf['LON'][i])
        masklat.append(pf['LAT'][i])
    elif pf["Masksd"][i] == 0:
        nomasklon.append(pf['LON'][i])
        nomasklat.append(pf['LAT'][i])
    else:
        unknownlon.append(pf['LON'][i])
        unknownlat.append(pf['LAT'][i])

trace1 = Scattermapbox(
    name="Buildings",
    mode="markers",
    lon=df['LAT'],
    lat=df['LON'],
    text=df['Location'],
    hoverinfo="lon+lat+text",
    marker=dict(symbol='square-stroked', size=12, color='black', opacity=1),
    legendgroup="Buildings",
)


def maketrace(name, lats, lons, dataframe, color, shape, group, showlegend,
              sd):
    return Scattermapbox(
        name=name,
        mode="markers",
        lon=lats,
        lat=lons,
        text="ID: " + dataframe['ID'].astype(str) +
        "<br>Mask/Social Distance Compliance: " + sd,
コード例 #14
0
def update_graph(value, slider_value, selectedData, prevLayout, mapControls):
    zoom = 12.0
    latInitial = 40.7272
    lonInitial = -73.991251
    bearing = 0

    listStr = get_lat_lon_color(selectedData, value, slider_value)

    if (prevLayout is not None and mapControls is not None
            and 'lock' in mapControls):
        zoom = float(prevLayout['mapbox']['zoom'])
        latInitial = float(prevLayout['mapbox']['center']['lat'])
        lonInitial = float(prevLayout['mapbox']['center']['lon'])
        bearing = float(prevLayout['mapbox']['bearing'])
    return go.Figure(
        data=Data([
            Scattermapbox(
                lat=eval(listStr)['Lat'],
                lon=eval(listStr)['Lon'],
                mode='markers',
                hoverinfo="lat+lon+text",
                text=eval(listStr).index.hour,
                marker=go.Marker(color=np.append(
                    np.insert(eval(listStr).index.hour, 0, 0), 23),
                                 colorscale=[[0, 'rgb(153,236,21)'],
                                             [0.04167, 'rgb(218,240,23)'],
                                             [0.0833, 'rgb(187,236,25)'],
                                             [0.125, 'rgb(157,232,27)'],
                                             [0.1667, 'rgb(128,228,29)'],
                                             [0.2083, 'rgb(102,224,31)'],
                                             [0.25, 'rgb(76,220,32)'],
                                             [0.292, 'rgb(52,216,34)'],
                                             [0.333, 'rgb(36,210,73)'],
                                             [0.375, 'rgb(37,208,66)'],
                                             [0.4167, 'rgb(38,204,88)'],
                                             [0.4583, 'rgb(40,200,109)'],
                                             [0.50, 'rgb(41,196,129)'],
                                             [0.54167, 'rgb(42,192,147)'],
                                             [0.5833, 'rgb(43,188,164)'],
                                             [1.0, 'rgb(97,48,153)']],
                                 opacity=0.5,
                                 size=5,
                                 colorbar=dict(thicknessmode="fraction",
                                               title="Time of<br>Day",
                                               x=0.935,
                                               xpad=0,
                                               nticks=24,
                                               tickfont=dict(color='white'),
                                               titlefont=dict(color='white'),
                                               titleside='right')),
            ),
            Scattermapbox(
                lat=[
                    "40.7505", "40.8296", "40.7484", "40.7069", "40.7527",
                    "40.7127", "40.7589", "40.8075", "40.7489"
                ],
                lon=[
                    "-73.9934", "-73.9262", "-73.9857", "-74.0113", "-73.9772",
                    "-74.0134", "-73.9851", "-73.9626", "-73.9680"
                ],
                mode='markers',
                hoverinfo="text",
                text=[
                    "Madison Square Garden", "Yankee Stadium",
                    "Empire State Building", "New York Stock Exchange",
                    "Grand Central Station", "One World Trade Center",
                    "Times Square", "Columbia University", "United Nations HQ"
                ],
                # opacity=0.5,
                marker=go.Marker(size=6, color="#ffa0a0"),
            ),
        ]),
        layout=Layout(
            autosize=True,
            height=750,
            margin=Margin(l=0, r=0, t=0, b=0),
            showlegend=False,
            mapbox=dict(
                accesstoken=mapbox_access_token,
                center=dict(
                    lat=latInitial,  # 40.7272
                    lon=lonInitial  # -73.991251
                ),
                style='dark',
                bearing=bearing,
                zoom=zoom),
            updatemenus=[
                dict(buttons=([
                    dict(args=[{
                        'mapbox.zoom': 12,
                        'mapbox.center.lon': '-73.991251',
                        'mapbox.center.lat': '40.7272',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='Reset Zoom',
                         method='relayout')
                ]),
                     direction='left',
                     pad={
                         'r': 0,
                         't': 0,
                         'b': 0,
                         'l': 0
                     },
                     showactive=False,
                     type='buttons',
                     x=0.45,
                     xanchor='left',
                     yanchor='bottom',
                     bgcolor='#323130',
                     borderwidth=1,
                     bordercolor="#6d6d6d",
                     font=dict(color="#FFFFFF"),
                     y=0.02),
                dict(buttons=([
                    dict(args=[{
                        'mapbox.zoom': 15,
                        'mapbox.center.lon': '-73.9934',
                        'mapbox.center.lat': '40.7505',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='Madison Square Garden',
                         method='relayout'),
                    dict(args=[{
                        'mapbox.zoom': 15,
                        'mapbox.center.lon': '-73.9262',
                        'mapbox.center.lat': '40.8296',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='Yankee Stadium',
                         method='relayout'),
                    dict(args=[{
                        'mapbox.zoom': 15,
                        'mapbox.center.lon': '-73.9857',
                        'mapbox.center.lat': '40.7484',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='Empire State Building',
                         method='relayout'),
                    dict(args=[{
                        'mapbox.zoom': 15,
                        'mapbox.center.lon': '-74.0113',
                        'mapbox.center.lat': '40.7069',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='New York Stock Exchange',
                         method='relayout'),
                    dict(args=[{
                        'mapbox.zoom': 15,
                        'mapbox.center.lon': '-73.785607',
                        'mapbox.center.lat': '40.644987',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='JFK Airport',
                         method='relayout'),
                    dict(args=[{
                        'mapbox.zoom': 15,
                        'mapbox.center.lon': '-73.9772',
                        'mapbox.center.lat': '40.7527',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='Grand Central Station',
                         method='relayout'),
                    dict(args=[{
                        'mapbox.zoom': 15,
                        'mapbox.center.lon': '-73.9851',
                        'mapbox.center.lat': '40.7589',
                        'mapbox.bearing': 0,
                        'mapbox.style': 'dark'
                    }],
                         label='Times Square',
                         method='relayout')
                ]),
                     direction="down",
                     pad={
                         'r': 0,
                         't': 0,
                         'b': 0,
                         'l': 0
                     },
                     showactive=False,
                     bgcolor="rgb(50, 49, 48, 0)",
                     type='buttons',
                     yanchor='bottom',
                     xanchor='left',
                     font=dict(color="#FFFFFF"),
                     x=0,
                     y=0.05)
            ]))