<filename>python/jimmy_plot/sweep_threshold.py
import os
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np

TEST_LIST_spec=[
    # "429.mcf", 
    # "433.milc", 
    # "435.gromacs", 
    "436.cactusADM", 
    # "437.leslie3d", 
    "444.namd", 
    # "445.gobmk", 
    "453.povray", 
    # "454.calculix", 
    # "456.hmmer", 
    # "458.sjeng",
    "459.GemsFDTD", 
    # "462.libquantum", 
    # "464.h264ref", 
    # "470.lbm",
    "471.omnetpp", 
    "473.astar", 
    # "481.wrf", \
    # "482.sphinx3", \
    ]

data_h1 = [0.65, 0.55, 0.67, 0.35, 0.32, 0.35]
data_fp1 =[0.21, 0.36, 0.43, 0.43, 0.22, 0.43]

data_h2 = [0.81, 0.73, 0.71, 0.45, 0.78, 0.62]
data_fp2 =[0.18, 0.26, 0.13, 0.38, 0.15, 0.43]

#1.344 thres, 1.4vdc
data_h3 = [-1, 0.93, 0.84, 0.50, 0.96, 0.98]
data_fp3 =[-1, 0.06, 0.10, 0.32, 0.01, 0.05]


data = {}
x_v = [0.04,0.07,0.095]
for idx, test in enumerate(TEST_LIST_spec):
    hr = [data_h1[idx],data_h2[idx],data_h3[idx]]
    fpr  = [data_fp1[idx],data_fp2[idx],data_fp3[idx]]
    data[test] = {"fpr":fpr,"hr":hr}

plot_path = "/home/jimmyjz2/plot/9_29-thres_sweep.jpg"
fig, axs = plt.subplots(2, figsize=(16,9))
axs[0].invert_xaxis()
axs[1].invert_xaxis()
data["436.cactusADM"]["fpr"] =  data["436.cactusADM"]["fpr"][0:2]
data["436.cactusADM"]["hr"] =  data["436.cactusADM"]["hr"][0:2]

for k,v in data.items():
    x = x_v[0:len(v["hr"])]
    x2 = [1.4*(1-i) for i in x]

    axs[0].plot(x2, v["hr"], label = k)
    axs[0].set_ylim([0,1])
    axs[0].set_xlabel("VE Threshold")
    axs[0].set_ylabel("Hitrate")

    # Shrink current axis by 20%
    box = axs[0].get_position()
    axs[0].set_position([box.x0, box.y0, box.width * 0.8, box.height])

    # Put a legend to the right of the current axis
    axs[0].legend(loc='center left', bbox_to_anchor=(1, 0.5))

    axs[1].plot(x2, v["fpr"], label = k)
    axs[1].set_ylim([0,1])
    axs[1].set_xlabel("VE Threshold")
    axs[1].set_ylabel("False Positive Rate")
    box = axs[1].get_position()
    axs[1].set_position([box.x0, box.y0, box.width * 0.8, box.height])

    # Put a legend to the right of the current axis
    axs[1].legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.savefig(plot_path,format='jpg')






<filename>python/jimmy_plot/sweep_threshold.py
import os
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np

TEST_LIST_spec=[
    # "429.mcf", 
    # "433.milc", 
    # "435.gromacs", 
    "436.cactusADM", 
    # "437.leslie3d", 
    "444.namd", 
    # "445.gobmk", 
    "453.povray", 
    # "454.calculix", 
    # "456.hmmer", 
    # "458.sjeng",
    "459.GemsFDTD", 
    # "462.libquantum", 
    # "464.h264ref", 
    # "470.lbm",
    "471.omnetpp", 
    "473.astar", 
    # "481.wrf", \
    # "482.sphinx3", \
    ]

data_h1 = [0.65, 0.55, 0.67, 0.35, 0.32, 0.35]
data_fp1 =[0.21, 0.36, 0.43, 0.43, 0.22, 0.43]

data_h2 = [0.81, 0.73, 0.71, 0.45, 0.78, 0.62]
data_fp2 =[0.18, 0.26, 0.13, 0.38, 0.15, 0.43]

#1.344 thres, 1.4vdc
data_h3 = [-1, 0.93, 0.84, 0.50, 0.96, 0.98]
data_fp3 =[-1, 0.06, 0.10, 0.32, 0.01, 0.05]


data = {}
x_v = [0.04,0.07,0.095]
for idx, test in enumerate(TEST_LIST_spec):
    hr = [data_h1[idx],data_h2[idx],data_h3[idx]]
    fpr  = [data_fp1[idx],data_fp2[idx],data_fp3[idx]]
    data[test] = {"fpr":fpr,"hr":hr}

plot_path = "/home/jimmyjz2/plot/9_29-thres_sweep.jpg"
fig, axs = plt.subplots(2, figsize=(16,9))
axs[0].invert_xaxis()
axs[1].invert_xaxis()
data["436.cactusADM"]["fpr"] =  data["436.cactusADM"]["fpr"][0:2]
data["436.cactusADM"]["hr"] =  data["436.cactusADM"]["hr"][0:2]

for k,v in data.items():
    x = x_v[0:len(v["hr"])]
    x2 = [1.4*(1-i) for i in x]

    axs[0].plot(x2, v["hr"], label = k)
    axs[0].set_ylim([0,1])
    axs[0].set_xlabel("VE Threshold")
    axs[0].set_ylabel("Hitrate")

    # Shrink current axis by 20%
    box = axs[0].get_position()
    axs[0].set_position([box.x0, box.y0, box.width * 0.8, box.height])

    # Put a legend to the right of the current axis
    axs[0].legend(loc='center left', bbox_to_anchor=(1, 0.5))

    axs[1].plot(x2, v["fpr"], label = k)
    axs[1].set_ylim([0,1])
    axs[1].set_xlabel("VE Threshold")
    axs[1].set_ylabel("False Positive Rate")
    box = axs[1].get_position()
    axs[1].set_position([box.x0, box.y0, box.width * 0.8, box.height])

    # Put a legend to the right of the current axis
    axs[1].legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.savefig(plot_path,format='jpg')






# "429.mcf", # "433.milc", # "435.gromacs", # "437.leslie3d", # "445.gobmk", # "454.calculix", # "456.hmmer", # "458.sjeng", # "462.libquantum", # "464.h264ref", # "470.lbm", # "481.wrf", \ # "482.sphinx3", \ #1.344 thres, 1.4vdc # Shrink current axis by 20% # Put a legend to the right of the current axis # Put a legend to the right of the current axis