Browse Source

new way of making graphs

Stan Gurtler 2 years ago
parent
commit
83185f3730
1 changed files with 21 additions and 11 deletions
  1. 21 11
      prsona/scripts/make_graphs.py

+ 21 - 11
prsona/scripts/make_graphs.py

@@ -22,7 +22,7 @@ PLOT_OPTIONS = {
             "color": "green"
         }, 
         "no": {
-            "legend": 'Workload: "no"',
+            "legend": 'Workload: "none"',
             "marker": '*',
             "color": "blue"
         },
@@ -37,7 +37,7 @@ PLOT_OPTIONS = {
             "color": "green"
         }, 
         "hbcno": {
-            "legend": 'Workload: "no"',
+            "legend": 'Workload: "none"',
             "marker": '*',
             "color": "blue"
         }
@@ -165,6 +165,9 @@ def cd(newdir, makenew):
 def genericCube(x, a, b, c, d):
     return a * (x * x * x) + b * (x * x) + c * x + d
 
+def onlyCube(x, a):
+    return a * (x * x * x)
+
 def readData(dataDirectory):
     serverData = {}
     clientData = {}
@@ -383,6 +386,7 @@ def plotComparison(data, dataParts, xVariable, lineVariable, whichGraph, **kwarg
     legendBBoxAnchor = kwargs['legendBBoxAnchor'] if 'legendBBoxAnchor' in kwargs else (0, 1)
     extraFit = kwargs['extraFit'] if 'extraFit' in kwargs else False
     loglog = kwargs['loglog'] if 'loglog' in kwargs else False
+    loglinear = kwargs['loglinear'] if 'loglinear' in kwargs else False
     yLim = kwargs['yLim'] if 'yLim' in kwargs else False
     aspect = kwargs['aspect'] if 'aspect' in kwargs else None
     ignoreWorkload = kwargs['ignoreWorkload'] if 'ignoreWorkload' in kwargs else False
@@ -431,6 +435,7 @@ def plotComparison(data, dataParts, xVariable, lineVariable, whichGraph, **kwarg
         xSelection = [int(x) for x in data['all']['2']['5'].keys()]
         xSelection.sort()
 
+    loglogLineFit = False
     for selection in lineSelection:
         xs = []
         xTicks = []
@@ -492,6 +497,12 @@ def plotComparison(data, dataParts, xVariable, lineVariable, whichGraph, **kwarg
                 popt, pcov = curve_fit(genericCube, xs, ys)
                 beyondXs = np.linspace(xs[-1], 100, 50)
                 ax.plot(beyondXs, genericCube(beyondXs, *popt), linestyle='--', color=color)
+            if loglog and not loglogLineFit:
+                popt, pcov = curve_fit(onlyCube, xs, ys)
+                moreXs = np.linspace(5, 50, 45)
+                labelString = "Line of best fit with slope = 3"
+                ax.plot(moreXs, onlyCube(moreXs, *popt), label=labelString, color="black")
+                loglogLineFit = True
         
     ax.set_title(title, fontsize='x-large')
     ax.set_xlabel(xLabel, fontsize='large')
@@ -500,15 +511,12 @@ def plotComparison(data, dataParts, xVariable, lineVariable, whichGraph, **kwarg
     if loglog:
         ax.set_yscale("log")
         ax.set_xscale("log")
-
-        moreXs = np.linspace(5, 50, 45)
-        divisor = 32
-        if lineVariable == "workload":
-            divisor = LOGLOG_FIT_OPTIONS[lineVariable][whichGraph][dataParts[3]]
-        if lineVariable == "lambda" or lineVariable == "numServers":
-            divisor = LOGLOG_FIT_OPTIONS[lineVariable][whichGraph]
-        labelString = "$y = \\frac{x^3}{" + str(divisor) + "}$"
-        ax.plot(moreXs, genericCube(moreXs, 1.0/divisor, 0, 0, 0), label=labelString, color="black")
+        ax.set_xticks([5, 10, 20, 30, 40, 50])
+        ax.set_xticklabels(["5", "10", "20", "30", "40", "50"])
+    if loglinear:
+        ax.set_xscale("log")
+        ax.set_xticks([5, 10, 20, 30, 40, 50])
+        ax.set_xticklabels(["5", "10", "20", "30", "40", "50"])
     else:
         bottom, top = ax.get_ylim()
         bottom = (0 if bottom > 0 else bottom)
@@ -568,6 +576,8 @@ def main(dataDirectory, plotOptionsFile):
             kwargs["legendBBoxAnchor"] = anchor
         if "loglog" in option:
             kwargs["loglog"] = option["loglog"]
+        if "loglinear" in option:
+            kwargs["loglinear"] = option["loglinear"]
         if "yLim" in option:
             kwargs["yLim"] = option["yLim"]
         if "aspect" in option: