|
@@ -9,37 +9,64 @@ import json
|
|
|
import pandas as pd
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
+colorLookup = {
|
|
|
+ "google": "r",
|
|
|
+ "leaflet": "b",
|
|
|
+ "mapbox_feature": "g",
|
|
|
+ "mapbox_marker": "y",
|
|
|
+ "mapgl": "m",
|
|
|
+ "pigeons": "c"
|
|
|
+}
|
|
|
|
|
|
def readFile():
|
|
|
with open("time.json") as file:
|
|
|
timeList = json.load(file)
|
|
|
-
|
|
|
+
|
|
|
timeDf = pd.DataFrame(timeList)
|
|
|
+ print("number of tests:", timeDf.shape[0])
|
|
|
timeDf["markers"] = pd.to_numeric(timeDf["markers"], errors="raise")
|
|
|
+ print(timeDf.value_counts(subset=["id"]))
|
|
|
+ print(timeDf.value_counts(subset=["id", "type"]))
|
|
|
return timeDf
|
|
|
|
|
|
-def avgTimeMaps(df):
|
|
|
- avgDf = df.groupby(["id", "markers"]).mean().reset_index()
|
|
|
- avgDf = avgDf.pivot(index="markers", columns="id", values="time")
|
|
|
- avgDf.plot()
|
|
|
- plt.savefig("plots/mapsAvg.png")
|
|
|
+def timeMaps(df, plotTitle="plots/maps.png"):
|
|
|
+ fig, ax = plt.subplots(figsize=(20,12))
|
|
|
+ for mapId, mapDf in df.groupby(["id"]):
|
|
|
+ if mapId != "mapbox":
|
|
|
+ ax.scatter(mapDf["markers"], mapDf["time"], color=colorLookup.get(mapId))
|
|
|
+ mapAvgDf = mapDf.groupby(["markers"]).mean().reset_index()
|
|
|
+ ax.plot(mapAvgDf["markers"], mapAvgDf["time"], label=mapId, color=colorLookup.get(mapId))
|
|
|
+ else:
|
|
|
+ for markerType, typeDf in mapDf.groupby(["type"]):
|
|
|
+ mapTypeId = "mapbox_" + markerType
|
|
|
+ ax.scatter(typeDf["markers"], typeDf["time"], color=colorLookup.get(mapTypeId))
|
|
|
+ typeMapAvgDf = typeDf.groupby(["markers"]).mean().reset_index()
|
|
|
+ ax.plot(typeMapAvgDf["markers"], typeMapAvgDf["time"], label=mapTypeId, color=colorLookup.get(mapTypeId))
|
|
|
+
|
|
|
|
|
|
-def timeMaps(df):
|
|
|
- fig, ax = plt.subplots(figsize=(10,4))
|
|
|
- for key, grp in df.groupby(["id"]):
|
|
|
- ax.scatter(grp["markers"], grp["time"], label=key)#
|
|
|
ax.legend(title="Maps")
|
|
|
- plt.savefig("plots/maps.png")
|
|
|
+ plt.savefig(plotTitle)
|
|
|
|
|
|
-def mapboxTypes(df):
|
|
|
+def mapboxTypes(df, plotTitle="plots/mapbox.png"):
|
|
|
mapboxDf = df.dropna(subset=["type"])
|
|
|
- fig, ax = plt.subplots(figsize=(10,4))
|
|
|
- for key, grp in mapboxDf.groupby(["type"]):
|
|
|
- ax.scatter(grp["markers"], grp["time"], label=key)#
|
|
|
+ fig, ax = plt.subplots(figsize=(20,12))
|
|
|
+ for markerType, typeDf in mapboxDf.groupby(["type"]):
|
|
|
+ mapId = "mapbox_" + markerType
|
|
|
+ ax.scatter(typeDf["markers"], typeDf["time"], label=mapId, color=colorLookup.get(mapId))
|
|
|
+
|
|
|
+ typeAvgDf = typeDf.groupby(["markers"]).mean().reset_index()
|
|
|
+ ax.plot(typeAvgDf["markers"], typeAvgDf["time"], color=colorLookup.get(mapId))
|
|
|
+
|
|
|
ax.legend(title="Marker Type")
|
|
|
- plt.savefig("plots/mapbox.png")
|
|
|
+ plt.savefig(plotTitle)
|
|
|
+
|
|
|
+def smallValues(df):
|
|
|
+ df = df.loc[df["markers"] < 300]
|
|
|
+ timeMaps(df, "plots/mapsSmall.png")
|
|
|
+ mapboxTypes(df, "plots/mapboxSmall.png")
|
|
|
+
|
|
|
|
|
|
df = readFile()
|
|
|
-avgTimeMaps(df)
|
|
|
timeMaps(df)
|
|
|
-mapboxTypes(df)
|
|
|
+mapboxTypes(df)
|
|
|
+smallValues(df)
|