#!/usr/bin/python3 -u

# --------------------------------------------------------------

# Please adjust following values

text_file = "output.txt"  # this file contains lines of the form "Base (.+), Power (.+): Immortals/Digit: (.+)"
show_text = False
dot_size_factor = 5
x_size = 20

# --------------------------------------------------------------

# Don't edit after this line

import matplotlib.pyplot as plt # requires "python3 -m pip install matplotlib"
import math

fig = plt.figure()
ax = fig.add_subplot(111)

ax.set_xlabel('Base (b)')
ax.set_ylabel('Power (p)')

import re
regex = re.compile("Base (.+), Power (.+): Immortals/Digit: (.+)")
with open(text_file) as f:
    for line in f:
        result = regex.search(line)
        if result:
            b = result.group(1)
            p = result.group(2)
            x = math.floor(float(result.group(3)))
            xs = b
            ys = p

            if float(result.group(3)) == 0.0:
                c = "#dd0000"
                m = 'x'
                s = x_size
            elif math.floor(float(result.group(3))) == math.ceil(float(result.group(3))):
                c = "#008800"
                m = 'o' # filled_markers = ('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', 'P', 'X')
                s = x*dot_size_factor
            else:
                c = "#6666aa"
                m = 'o' # filled_markers = ('o', 'v', '^', '<', '>', '8', 's', 'p', '*', 'h', 'H', 'D', 'd', 'P', 'X')
                s = x*dot_size_factor

            ax.scatter(xs, ys, c=c, marker=m, s=s)
            if show_text and float(result.group(3)) > 0.0:
                ax.annotate(result.group(3),(xs,ys))

plt.show()

# --------------------------------------------------------------
