當前位置: 首頁>>代碼示例>>Python>>正文


Python Plot.plot2Subplots方法代碼示例

本文整理匯總了Python中plot.Plot.plot2Subplots方法的典型用法代碼示例。如果您正苦於以下問題:Python Plot.plot2Subplots方法的具體用法?Python Plot.plot2Subplots怎麽用?Python Plot.plot2Subplots使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plot.Plot的用法示例。


在下文中一共展示了Plot.plot2Subplots方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: plotIterations

# 需要導入模塊: from plot import Plot [as 別名]
# 或者: from plot.Plot import plot2Subplots [as 別名]
def plotIterations(player_number1, tx_node_id1, rx_node_id1, player_number2, tx_node_id2, rx_node_id2, c1=0, c2=0, TruncatedValues=True, saveImage = True):
    #This method will read the files which contains information about an experiment identified from c1 and c2, and then plot the results using Plot class
    path1 ="./iterations/c1_%d-c2_%d/player_%d_with_tx_%d_and_rx_%d.dat" %(c1, c2, player_number1, tx_node_id1, rx_node_id1)
    path2 ="./iterations/c1_%d-c2_%d/player_%d_with_tx_%d_and_rx_%d.dat" %(c1, c2,player_number2, tx_node_id2, rx_node_id2)
    
    if (not os.path.exists(path1) or not os.path.isfile(path1)):
        print "No data available for plotting iterations"
        return
    
    if (not os.path.exists(path2) or not os.path.isfile(path2)):
        print "No data available for plotting iterations"
        return
    
    f1 = open(path1, "r")
    f2 = open(path2, "r")
    
    #read first file
    iterations_list1 =[]
    labels1 = []
    #read first line, it's a  header
    f1.readline()
    while True:
        line = f1.readline()
        
        if not line:
            break
        
        #detect line which represent the starting of a new experiment
        if line[0:10] == "Experiment":
            iterations_list1.append([])
            line_list = line.split()
            if line_list[9]=="adaptive":
                labels1.append("cost=%s  gain=%s dB" %(line_list[9], line_list[22] ) )
            else:
                labels1.append("cost=%s  gain=%s dB" %(line_list[8], line_list[22] ) )
            continue
        
        line_list = line.split()
        try:
            if TruncatedValues:
                iterations_list1[-1].append(float(line_list[3]))
            else:
                iterations_list1[-1].append(float(line_list[5]))
        except:
            continue
    f1.close()
    
    #read second file
    iterations_list2 =[]
    labels2 = []
    #read first line, it's a  header
    f2.readline()
    while True:
        line = f2.readline()
        
        if not line:
            break
        
        if line[0:10] == "Experiment":
            iterations_list2.append([])
            line_list = line.split()
            if line_list[9] == "adaptive":
                labels2.append("cost=%s  gain=%s dB" %( line_list[9], line_list[22]) )
            else:
                labels2.append("cost=%s  gain=%s dB" %( line_list[8], line_list[22]) )
            continue
        
        line_list = line.split()
        try:
            if TruncatedValues:
                iterations_list2[-1].append(float(line_list[3]))
            else:
                iterations_list2[-1].append(float(line_list[5]))
        except:
            continue
    f2.close()
    
    if TruncatedValues:
        Plot.plot2Subplots(iterations_list1, iterations_list2, labels1, labels2, "Iterations", "Power [dBm]", "Best response evolution for player %d. Truncated values" %player_number1, "Best response evolution for player %d. Truncated values" %player_number2,c1, c2,ion=False,Truncated=TruncatedValues,SaveImg = saveImage )
    else:
        Plot.plot2Subplots(iterations_list1, iterations_list2, labels1, labels2, "Iterations", "Power [dBm]", "Best response evolution for player %d. Real values" %player_number1, "Best response evolution for player %d. Real values" %player_number2,c1, c2,ion=False,Truncated=TruncatedValues,SaveImg = saveImage )
開發者ID:adobekan,項目名稱:logatec-games,代碼行數:83,代碼來源:iterations.py


注:本文中的plot.Plot.plot2Subplots方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。