浏览代码

added highlight plot of two maps for presentation

Bernadette Elena Hammerle 3 年之前
父节点
当前提交
e4a72e5897
共有 1 个文件被更改,包括 36 次插入0 次删除
  1. 36 0
      src/database/dbAnalyser.py

+ 36 - 0
src/database/dbAnalyser.py

@@ -42,6 +42,7 @@ def timeMaps(df, plotTitle="maps.png"):
             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
@@ -81,6 +82,7 @@ def smallValues(df):
     df = df.loc[df["markers"] < 300]
     timeMaps(df, "mapsSmall.png")
     mapboxTypes(df, "mapboxSmall.png")
+    timeMapsHighlight(df, "mapsSmallHighlight.png")
 
 
 def avgPerMarkerNo(df, markerNo):
@@ -101,11 +103,45 @@ def avgPerMarkerNo(df, markerNo):
     print(resDf)
 
 
+def timeMapsHighlight(df, plotTitle="mapsHightlight.png"):
+    fig, ax = plt.subplots(figsize=(20,12))
+    plt.yticks(fontsize=15)
+    plt.xticks(fontsize=15)
+    for mapId, mapDf in df.groupby(["id"]):
+        if mapId != "mapbox":
+            if mapId == "leaflet":
+                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), linewidth=2)
+            else:
+                ax.scatter(mapDf["markers"], mapDf["time"], color=colorLookup.get(mapId), alpha=0.3)
+                mapAvgDf = mapDf.groupby(["markers"]).mean().reset_index()
+                ax.plot(mapAvgDf["markers"], mapAvgDf["time"], label=mapId, color=colorLookup.get(mapId), linewidth=1, alpha=0.3)
+      
+        else:
+            for markerType, typeDf in mapDf.groupby(["type"]):
+                mapTypeId = "mapbox_" + markerType
+                if markerType == "feature":
+                    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), linewidth=2)
+                else:
+                    ax.scatter(typeDf["markers"], typeDf["time"], color=colorLookup.get(mapTypeId), alpha=0.3)
+                    typeMapAvgDf = typeDf.groupby(["markers"]).mean().reset_index()
+                    ax.plot(typeMapAvgDf["markers"], typeMapAvgDf["time"], label=mapTypeId, color=colorLookup.get(mapTypeId), linewidth=1, alpha=0.3)
+
+    ax.legend(title="Marker Type", fontsize=17, title_fontsize=20)
+    ax.set_xlabel("Number of Markers", fontsize=20)
+    ax.set_ylabel("Time (ms)", fontsize=20)
+    ax.set_title("Map Libraries - Marker", fontsize=25)
+    folder = os.path.dirname(os.path.abspath(__file__)) + "/plots/"
+    plt.savefig(folder + plotTitle, bbox_inches="tight")
 
 df = readFile()
 avgPerMarkerNo(df, 100)
 avgPerMarkerNo(df, 1000)
 avgPerMarkerNo(df, 10000)
 timeMaps(df)
+timeMapsHighlight(df)
 mapboxTypes(df)
 smallValues(df)