-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisualize.py
More file actions
20 lines (16 loc) · 940 Bytes
/
visualize.py
File metadata and controls
20 lines (16 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import plotly.express as px
import pandas as pd
def visualize_diff(df, date, scale=["red", "green", "blue"]):
n_df = df.loc[(df["Date"] == int(date)) & (df["Latitude"] != 0)]
n_df["diff"] = n_df["This_Week"] - n_df["Last_Week"]
fig = px.scatter_mapbox(n_df, lat="Latitude", lon="Longitude", color="diff", size="FSC",
color_continuous_scale=scale, color_continuous_midpoint=0, zoom=4,
mapbox_style="carto-positron")
fig.show()
def visualize_diff_timeline(df, scale=["red", "green", "blue"]):
n_df = df.loc[df["Latitude"] != 0]
n_df["diff"] = n_df["This_Week"] - n_df["Last_Week"]
fig = px.scatter_mapbox(n_df, lat="Latitude", lon="Longitude", color="diff", size="FSC",
animation_frame="Date", color_continuous_scale=scale, color_continuous_midpoint=0,
range_color=[-0.25, 0.25], zoom=4, mapbox_style="carto-positron")
fig.show()