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


Python matplotlib.legend方法代碼示例

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


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

示例1: get_legend

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import legend [as 別名]
def get_legend(self):
        """Return the `Legend` instance, or None if no legend is defined."""
        return self.legend_ 
開發者ID:Relph1119,項目名稱:GraphicDesignPatternByPython,代碼行數:5,代碼來源:_base.py

示例2: plot_chart

# 需要導入模塊: import matplotlib [as 別名]
# 或者: from matplotlib import legend [as 別名]
def plot_chart(log_file, path_to_png, mode=PLOT_MODE.NORMAL):

    mean_ap=0
    phases, detected_mean_ap = parse_log(log_file)
    if detected_mean_ap != None:
        mean_ap=detected_mean_ap

    print "Processing %s with mAP=%f" % (path_to_png, mean_ap)

    plt.figure(1, figsize=(8, 32))

    end_phase=min(len(phases), 4)
    for phase_idx in range(0,end_phase):
        phase=np.array(phases[phase_idx])
        plt.subplot(411+phase_idx)
        label = LABELS[phase_idx]
        plt.title("%s%s"%( "mAP = %f    "%mean_ap if phase_idx == 0 else "",str(label[phase_idx])))


        for x_label,y_label in FIELDS[phase_idx]:
            ## TODO: more systematic color cycle for lines
            color = [random.random(), random.random(), random.random()]
            linewidth = 0.75
            ## If there too many datapoints, do not use marker.
    ##        use_marker = False
            use_marker = True

            # if (mode==PLOT_MODE.MOVING_AVG):

            x_data = [row[x_label] for row in phase]
            y_data = [row[y_label] for row in phase]


            if mode==PLOT_MODE.MOVING_AVG:
                y_data=moving_average(y_data, 100)
            elif mode == PLOT_MODE.BOTH:
                marker = random_marker()
                plt.plot(x_data, y_data, label=label, color=color,
                         marker=marker, linewidth=linewidth)

                color = [random.random(), random.random(), random.random()]
                y_data = moving_average(y_data, 100)

            if not use_marker:
                plt.plot(x_data, y_data, label = label, color = color,
                         linewidth = linewidth)
            else:
                marker = random_marker()
                plt.plot(x_data, y_data, label = label, color = color,
                         marker = marker, linewidth = linewidth)

    #legend_loc = get_legend_loc(chart_type)
    #plt.legend(loc = legend_loc, ncol = 1) # ajust ncol to fit the space
    #plt.xlabel(x_axis_field)
    #plt.ylabel(y_axis_field)

    # plt.annotate(fontsize='xx-small')
    print "Saving...",
    plt.savefig(path_to_png, dpi=600)
    print "done"
    plt.show() 
開發者ID:djdam,項目名稱:faster-rcnn-scenarios,代碼行數:63,代碼來源:plot.py


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