예제 #1
0
파일: box.py 프로젝트: swe4s/ss_plots
def main():
    args = plot_lib.get_args('Make a simple box plot.')

    names = []
    V = []
    i = 0
    for l in open(args.in_file):
        A = l.rstrip().split()
        names.append(A[0])
        V.append([float(v) for v in A[1:]])

    fig = plt.figure(figsize=(args.width, args.height), dpi=300)

    ax = fig.add_subplot(1, 1, 1)

    ax.boxplot(V)

    ax.set_xticklabels(names)

    ax.set_xlabel(args.x_label)
    ax.set_ylabel(args.y_label)
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)

    plt.savefig(args.out_file, bbox_inches='tight')
예제 #2
0
def main():
    args = plot_lib.get_args('Make a simple scatter plot.')

    names = []
    X = []
    Y = []
    i = 0
    for l in open(args.in_file):
        A = l.rstrip().split()
        if len(A) == 3:
            names.append(A[0] + ' ' + A[1])
            X.append(float(A[2]))
        if len(A) == 2:
            names.append(A[0])
            X.append(float(A[1]))
    
    i = 0
    for l in open(args.in_file2):
        B = l.rstrip().split()
        if len(B) == 3:
            if (B[0] + ' ' + B[1]) == names[i]:
                Y.append(float(B[2]))
                i = i + 1
            else:
                continue
        elif len(B) == 2:
            if B[0] == names[i]:
                Y.append(float(B[1]))
                i = i + 1
            else:
                continue

    clean_names = []     
    for name in names:
        new_name = name.strip("''[]")
        clean_names.append(new_name)
        
    fig = plt.figure(figsize=(args.width,args.height),dpi=300)

    ax = fig.add_subplot(1,1,1)

    ax.plot(X, Y, '.', ms=3, alpha=1)

    if len(clean_names) > 0:
        for i in range(len(clean_names)):
            ax.text(X[i],Y[i],clean_names[i], fontsize=4)

    ax.set_xlabel(args.x_label)
    ax.set_ylabel(args.y_label)
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)

    plt.savefig(args.out_file,bbox_inches='tight')
예제 #3
0
def main():
    args = plot_lib.get_args('Make a simple histogram.')

    V = []
    for l in open(args.in_file):
        A = l.rstrip().split()
        for a in A:
            V.append(float(a))

    fig = plt.figure(figsize=(args.width, args.height), dpi=300)

    ax = fig.add_subplot(1, 1, 1)

    ax.hist(V)

    ax.set_xlabel(args.x_label)
    ax.set_ylabel(args.y_label)
    #ax.spines['top'].set_visible(False)
    #ax.spines['right'].set_visible(False)

    plt.savefig(args.out_file, bbox_inches='tight')
예제 #4
0
def main():
    args = plot_lib.get_args('Make a simple scatter plot.')

    names = []
    X = []
    Y = []
    i = 0
    for l in open(args.in_file):
        A = l.rstrip().split()
        if len(A) == 3:
            names.append(A[0])
            X.append(float(A[1]))
            Y.append(float(A[2]))
        if len(A) == 2:
            X.append(float(A[0]))
            Y.append(float(A[1]))
        elif len(A) == 1:
            X.append(float(i))
            Y.append(float(A[0]))
            i += 1

    fig = plt.figure(figsize=(args.width, args.height), dpi=300)

    ax = fig.add_subplot(1, 1, 1)

    ax.plot(X, Y, '.', ms=3, alpha=1)

    if len(names) > 0:
        for i in range(len(names)):
            ax.text(X[i], Y[i], names[i], fontsize=4)

    ax.set_xlabel(args.x_label)
    ax.set_ylabel(args.y_label)
    ax.spines['top'].set_visible(False)
    ax.spines['right'].set_visible(False)

    plt.savefig(args.out_file, bbox_inches='tight')