import numpy as np
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import csv

plt.switch_backend('TkAgg')

"""
def randrange(n, vmin, vmax):
    return (vmax - vmin)*np.random.rand(n) + vmin

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n = 100
for c, m, zl, zh in [('r', 'o', -50, -25), ('b', '^', -30, -5)]:
    xs = randrange(n, 23, 32)
    ys = randrange(n, 0, 100)
    zs = randrange(n, zl, zh)
    ax.scatter(xs, ys, zs, c=c, marker=m)

ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')

plt.show()
"""



fn = "preset.csv"

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.set_xlabel('Threshold')
ax.set_ylabel('Lower')
ax.set_zlabel('Upper')


with open(fn) as f:
    rd = csv.reader(f)

    rd.next()

    for x in rd:
        label = x[0]
        ch    = x[1]
        mode  = x[2]
        thresh= x[3]
        upr   = x[4]
        lwr   = x[5]
        offs  = x[6]

        c = 'b'
        if float(mode)==4:
            c = 'g'
        if float(mode)==0:
            c = 'r'
            
        lbl = "%s-%s" % (label,ch)

        x = float(thresh)
        y = float(lwr)
        z = float(upr)
        ax.scatter(x,y,z,c=c)

        ax.text(x,y,z,  '%s' % (lbl), size=10, zorder=1,  color='k')
        

plt.show()
        
