예제 #1
0
def print_plot(items,
               x,
               y=None,
               sort=None,
               fillx=False,
               title=None,
               grid=False,
               marker=None,
               color=None,
               background_color=None,
               axes_color=None):
    df = items_to_dataframe(items, sort=sort)
    x_list = df[x].tolist()
    y_list = df[y].tolist() if y else None
    _x = df['timestamp'].tolist() if x in DATE_FIELDS else df[x]

    if y is None:
        plt.scatter(_x, marker=marker, color=color, fillx=fillx)
    else:
        plt.plot(_x, y_list, marker=marker, color=color, fillx=fillx)
        plt.xticks(_x, x_list)

    if title is not None:
        plt.title(title)

    if grid:
        plt.grid(True, True)

    if background_color is not None:
        plt.canvas_color(background_color)
        plt.axes_color(background_color)
    if axes_color is not None:
        plt.ticks_color(axes_color)

    plt.show()
예제 #2
0
def print_diff(diff, show_plot=False):
    mean_prefix = '+' if diff.r1['mean'] < diff.r2['mean'] else '-'
    median_prefix = '+' if diff.r1['percentile']['50'] < diff.r2['percentile'][
        '50'] else '-'
    print(
        f'| Version |         Mean ±    Stdev |        Min |     Median |         Q3 |        Max |'
    )
    print(
        f"|   V1    |   {diff.r1['mean']:10.3f} ± {diff.r1['stdev']:8.3f} | {diff.r1['min']:10.3f} | {diff.r1['percentile']['50']:10.3f} | {diff.r1['percentile']['75']:10.3f} | {diff.r1['max']:10.3f} |"
    )
    print(
        f"|   V2    |   {diff.r2['mean']:10.3f} ± {diff.r2['stdev']:8.3f} | {diff.r2['min']:10.3f} | {diff.r2['percentile']['50']:10.3f} | {diff.r2['percentile']['75']:10.3f} | {diff.r2['max']:10.3f} |"
    )
    print(
        f'├---------┴-------------------------┴------------┴------------┴------------┴------------┘'
    )
    print(
        f"|               {mean_prefix}{diff.mean_diff:7.2f}%                           {median_prefix}{diff.median_diff:7.2f}%   "
    )
    print(f'{diff.ptext}')
    print(f'{diff.significance}')
    print('')
    if show_plot:
        plt.subplots(2, 1)
        plt.subplot(1, 1)
        plt.scatter(diff.r1.get('samples', diff.r1['mean']), label='v1')
        plt.subplot(2, 1)
        plt.scatter(diff.r2.get('samples', diff.r2['mean']), label='v2')
        plt.show()
예제 #3
0
 def plot_score_trace(self, t, R_scores):
     r = R_scores.shape[0]
     plt.clear_plot()
     plt.set_output_file(self._logfile)
     for i in range(self.g.p["mcmc"]["n_indep"]):
         if t < r:
             plt.scatter(R_scores[:t, i], label=str(i), line_color="red")
         else:
             plt.scatter(R_scores[np.r_[(t % r):r, 0:(t % r)], i],
                         label=str(i),
                         line_color="red")
     plt.figsize(80, 20)
     plt.ticks(4, 4)
     if t < 1000:
         xticks = [int(w * t) for w in np.arange(0, 1 + 1 / 3, 1 / 3)]
         xlabels = [str(round(x / 1000, 1)) + "k" for x in xticks]
     else:
         xticks = [0, 333, 666, 999]
         xlabels = [str(round((x + t) / 1000, 1)) + "k" for x in xticks]
     plt.xticks(xticks, xlabels)
     plt.canvas_color("none")
     plt.axes_color("none")
     plt.ticks_color("none")
     plt.show()
     print(file=self._logfile)
     self._logfile.flush()
def plot_terminal(data, title, xtitle):
    """
    Plot data to the terminal using plotext
    """
    import plotext as plt
    x = data.index.tolist()
    y = data[title].tolist()

    plt.scatter(x, y)
    plt.title(title)
    plt.xlabel(xtitle)
    plt.plot_size(100, 30)
    plt.show()
예제 #5
0
    # Current is the last index of all trades
    current = y[-1]

    # Show red or green chart if price has declined since opening
    if current >= opening:
        color = "green"
    else:
        color = "tomato"

    #For formating
    plt.clear_plot()
    plt.clear_terminal()

    plt.scatter(y,
                point_color=color,
                fill=True,
                label=ticker + "- Open:" + str(opening) + " Current:" +
                str(current) + "1d High:" +
                str(current_high))  # Labled as Open: , Current: , High:

    #Most recent hours of trades will be highlighted blue
    plt.scatter(list(range(540, 600)),
                y[-60:],
                fill=True,
                label="Current Hour",
                point_color="blue")

    #More formating
    plt.canvas_color('none')
    plt.axes_color("none")
    plt.grid(False, False)
    plt.axes(False, False)
예제 #6
0
        yield count_lines(govc(*args))


if __name__ == '__main__':
    counts = 200  # number of data points
    interval = 0  # seconds per count

    xs = range(1, counts + 1)
    ys = []

    plt.title("GOVC Session Count")
    plt.clc()
    plt.xlim(xs[0], xs[-1])
    plt.xticks(ticks=[1, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200])

    for y in generate_counts("session.ls"):
        ys.append(y)
        while len(ys) > counts:
            ys.pop(0)
        y_min, y_max = min(ys), max(ys) + 1
        plt.yticks(ticks=range(y_min, y_max))
        plt.ylim(y_min, y_max)
        #plt.ylim(150,165)

        plt.cld()
        plt.clt()
        plt.scatter(xs, ys, marker="dot")

        plt.sleep(interval)
        plt.show()
예제 #7
0
import plotext as plt

# format: <<ID:default_value>>
scatter_size = <<SCATTER_SIZE:1>>
labels = <<LABELS:None>>
h = <<HEIGHT:None>>
w = <<WIDTH:None>>
vv = <<DATA:[]>>

if w is not None:
    plt.figure(figsize=(w*cm, h*cm))

# scatter
for ii in range(len(vv)):
    v = vv[ii]
    x = [v[2*i] for i in range(len(v)//2)]
    y = [v[2*i+1] for i in range(len(v)//2) if 2*i + 1 < len(v)]
    if labels and ii < len(labels):
        label = labels[ii]
        plt.scatter(x, y, label=label)
    else:
        plt.scatter(x, y)

plt.canvas_color('black')
plt.axes_color('black')
plt.ticks_color('white')
if w is not None:
    plt.plot_size(w, h)
plt.show()
예제 #8
0
# count number of filtered sequences
filter_data_size = len(filter_list)

###################################
print('-' * 45)
print('[Number of total sequences]:\t  ' + str(data_size))
print('[Minimum sequence length]:\t  ' + str(min_length_def) + ' bp')
print('[Maximum sequence length]:\t  ' + str(max_length_def) + ' bp')
print('-' * 45)
print('[Number of filtered sequences]:\t  ' + str(filter_data_size))
print('[Minimum sequence length (user)]: ' + str(min_length) + ' bp')
print('[Maximum sequence length (user)]: ' + str(input_length_max) + ' bp')
print('-' * 45)

###################################
# plot in terminal
import plotext as plt
plt.scatter(length_list)
plt.plotsize(40, 20)
plt.show()

###################################
# input file close
input.close()
# output file close
if args.output is not None:
    out.close()

###################################
# End of script
예제 #9
0
def show_statistics(rule_file=None, rule_set=None, indx=None):
    interface = None
    if rule_set == "-e":
        interface = "external"
    elif rule_set == "-i":
        interface = "internal"
    logs = utils.load_logs('logs.json')
    print("")
    print("-" * 13, "OVERALL FIREWALL STATISTICS", "-" * 13)
    print("TOTAL PACkETS RECEIVED BY THE FIREWALL: ", logs["total_packets"])
    print("TOTAL PACkETS DROPPED BY THE FIREWALL: ", logs["total_dropped"])
    if rule_file != None:
        if interface != None:
            print("")
            print("-" * 12, interface.upper(), "INTERFACE STATISTICS",
                  "-" * 12)
            print("TOTAL PACKETS RECEIVED ON", interface.upper(),
                  "INTERFACE: ", logs[rule_file][interface]["total_packets"])
            print("TOTAL PACKETS DROPPED ON", interface.upper(), "INTERFACE: ",
                  logs[rule_file][interface]["total_dropped"])
            if indx != None:
                if indx in logs[rule_file][interface]:
                    print("\nTOTAL PACKETS DROPPED DUE TO RULE", indx, "ON",
                          interface.upper(), "INTERFACE :",
                          logs[rule_file][interface][indx])
                else:
                    print("Invalid rule index!")
        else:
            print("")
            print("-" * 12, "EXTERNAL INTERFACE STATISTICS", "-" * 12)
            print("TOTAL PACKETS RECEIVED ON EXTERNAL INTERFACE: ",
                  logs[rule_file]["external"]["total_packets"])
            print("TOTAL PACKETS DROPPED ON EXTERNAL INTERFACE: ",
                  logs[rule_file]["external"]["total_dropped"])
            print("")
            print("-" * 12, "INTERNAL INTERFACE STATISTICS", "-" * 12)
            print("TOTAL PACKETS RECEIVED ON INTERNAL INTERFACE: ",
                  logs[rule_file]["internal"]["total_packets"])
            print("TOTAL PACKETS DROPPED ON INTERNAL INTERFACE: ",
                  logs[rule_file]["internal"]["total_dropped"])
    else:
        print("")
        print("-" * 16, "ICMP FLOOD STATISTICS", "-" * 16)
        print("FLOODS ENCOUNTERED SO FAR: ", logs["icmp_floods"])
        print("PACKETS DROPPED DURING ICMP BLOCK:", logs["icmp_dropped"])
        print("")
        print("-" * 22, "PPS INFO", "-" * 22)
        print("MAXIMUM PPS SO FAR: ", logs["max_pps"])
        print("")
        title = "-" * 18 + "NETWORK TRAFFIC" + "-" * 18
        net_traffic = logs["traffic"]
        max_sec = max(np.array(list(net_traffic.keys())).astype(int))
        packets_num = np.zeros(max_sec + 1)
        for i in net_traffic:
            packets_num[int(i)] = net_traffic[i]
        packets_num = packets_num.astype(int)
        plt.scatter(np.arange(max_sec + 1), packets_num, fillx=True)
        plt.figsize(80, 20)
        plt.title(title)
        plt.xlabel("Time")
        plt.ylabel("Packets")
        plt.show()