Пример #1
0
def draw_graph_style(graph_data):
    (items, antennas, edges) = graph_data
    antennas = antennas.tolist()
    print "Num styles:", sum([len(x[1]) for x in items])
    print "Num categories:", len(items)
    print "Num antennas:", len(antennas)
    print "Num edges:", len(edges)
    G = nx.Graph()
    for (category, style) in items:
        G.add_nodes_from(style)
    G.add_nodes_from(antennas)
    G.add_weighted_edges_from(edges)

    # Draw network
    pos = nx.graphviz_layout(G, prog='neato')
    colors = get_cmap(len(items))
    for index, (category, style) in enumerate(items):
        nx.draw_networkx_nodes(G, pos, nodelist=style, node_color = colors(index), node_size=100, alpha=0.8)
    nx.draw_networkx_nodes(G, pos, nodelist=antennas, node_color='w', node_size=150, alpha=0.8, label=[str(x) for x in antennas])
    nx.draw_networkx_edges(G, pos, width=1,alpha=0.5)
    plt.axis('off')
    lines = [mlines.Line2D(range(1), range(1), marker='o',markerfacecolor="w",markersize=5)]
    for i in range(len(items)):
        lines.append(mlines.Line2D(range(1), range(1), marker='o',markerfacecolor=colors(i),markersize=5))

    plt.legend(lines, ["Antennas"] + [x[0] for x in items],prop={'size':9})
    day = sys.argv[1].split(".")[0][-1]
    plt.title("Relative map of styles and antennas using inverse max counts and counts > 100 on day %s data" %day)
    plt.show()
Пример #2
0
def draw_bboxes(img, bboxes, color=(0, 128, 255), scale=2):
    """
    Given CT scan in numpy, draw bounded boxes on each slice up within 2x OAR size.
    img: [D,H,W] or [D,H,W,3]
    bboxes: [num, 4] or [num, 5] with dimension 0 probability
    color: RGB, default (0,128,255)
    scale: how big square box relative to the OAR, default 2
    """
    assert img.ndim == 3 or img.ndim == 4
    if img.ndim == 3:
        img = np.repeat(img[:, :, :, np.newaxis], 3, axis=3)

    num = int(len(bboxes))
    colors = get_cmap(num)
    for i, box in enumerate(bboxes):
        if len(box) == 6:
            img = draw_one_bbox(img, box, list(colors(i))[:-1], scale, '')
        elif len(box) == 7:
            p = box[0]
            text = '%.2f' % (p)
            img = draw_one_bbox(img, box[1:],
                                list(colors(i))[:-1], scale, text)
        else:
            raise NotImplementedError

    return img
Пример #3
0
def plot_line_gradients(ax,s,names,cmap,iphase,irefs,itau,iwvls,pos,normalize=False):
    """ Make multiple lines on the subplot ax of the spectra s, for the case defined by names with the cmap
      for one particular phase (iphase), range of refs (irefs) and at one itau. Returns the axis handles for the thin and thick ref """
    rf = range(irefs[0],irefs[1])
    colors = plt.cm._generate_cmap(cmap,int(len(rf)*2.25))
    for ir in rf:
        if not(normalize):
            a1 = ax.plot(s.wv,s.sp[iphase,iwvls,0,ir,itau],
                         color=(0.2,0.2,0.2),
                         lw=1.0+1.4*float(ir)/irefs[1])
            ax.plot(s.wv,s.sp[iphase,iwvls,0,ir,itau],
                     color=colors(ir),
                     lw=1.0+1.3*float(ir)/irefs[1])
            ax.text(pos[0],pos[1],names,color=colors(irefs[1]))
        else:
            a1 = ax.plot(s.wv,norm2max(s.sp[iphase,iwvls,0,ir,itau]),
                         color=(0.2,0.2,0.2),
                         lw=1.0+1.4*float(ir)/irefs[1])
            ax.plot(s.wv,norm2max(s.sp[iphase,iwvls,0,ir,itau]),
                     color=colors(ir),
                     lw=1.0+1.3*float(ir)/irefs[1])    
            ax.text(pos[0],pos[1]/0.22,names,color=colors(irefs[1]))
        if ir == rf[0]:
            alow = a1
        if ir == rf[-1]:
            ahigh = a1
    return [alow,ahigh]
Пример #4
0
def get_color_list(legend_num):
    colors_list = []
    if legend_num <= 10:
        colors = cm.get_cmap("tab10")
        for i in range(legend_num):
            colors_list.append(colors(i))
    elif legend_num <= 20:
        colors = cm.get_cmap("tab20")
        for i in range(legend_num):
            colors_list.append(colors(i))
    else:
        colors = cm.get_cmap('gist_rainbow', 128)
        for i in range(legend_num):
            color_grade = i / legend_num
            colors_list.append(colors(color_grade))
    return colors_list
Пример #5
0
    def __init__(self,
                 signals,
                 sample_rate,
                 t_start,
                 scatter_indexes,
                 scatter_channels,
                 scatter_colors=None,
                 channel_names=None):
        InMemoryAnalogSignalSource.__init__(self,
                                            signals,
                                            sample_rate,
                                            t_start,
                                            channel_names=channel_names)
        self.with_scatter = True

        #todo test and assert self.scatter_indexes sorted for eack k
        self.scatter_indexes = scatter_indexes
        self.scatter_channels = scatter_channels
        self.scatter_colors = scatter_colors

        self._labels = list(self.scatter_indexes.keys())

        if self.scatter_colors is None:
            self.scatter_colors = {}
            n = len(self._labels)
            colors = matplotlib.cm.get_cmap('Accent', n)
            for i, k in enumerate(self._labels):
                self.scatter_colors[k] = matplotlib.colors.to_hex(colors(i))
Пример #6
0
def highlight(text, vocab):
    text = text.split()

    colors = mpl.colors.LinearSegmentedColormap.from_list(
        'clrs', ['#ffffff', '#ffcd81'])
    hilited = []

    i = 0
    n = 3
    while i < len(text):
        grams = []
        for g in range(n):
            words = ' '.join(text[i:i + g])
            if words.lower() in vocab:
                grams.append([vocab[words.lower()], words, g])

        if grams:
            imp, words, g = max(grams)
            clr = mpl.colors.to_hex(colors(imp))
            hilited.append(
                '<span style="background-color:{};">{}</span>'.format(
                    clr, words))
            i += g
        else:
            hilited.append(text[i])
            i += 1

    return ' '.join(hilited)
Пример #7
0
def make_gant_chart(n_machines, n_jobs, makespan, data, title):
    #colors_list = list(colors._colors_full_map.values())
    colors_list = colors(n_jobs)
    fig, ax = plt.subplots()
    color_job = {}
    for i in range(n_machines):
        temp = []
        color = []
        for j in range(len(data[i])):
            [job_id, start_time, end_time] = data[i][j]
            temp.append((start_time, end_time - start_time))
            color.append(colors_list[job_id])
            if job_id not in color_job:
                color_job[job_id] = colors_list[job_id]
        ax.broken_barh(temp, (y_width * i, y_width), facecolors=color)
    ax.set_ylim(0, n_machines * y_width)
    ax.set_xlim(0, makespan + 0.2 * makespan)
    ax.set_xlabel('time')
    ax.set_ylabel('machine num')
    label_place = [
        i for i in range(int(y_width / 2), (n_machines) * y_width, y_width)
    ]
    ax.set_yticks(label_place)
    label = [i for i in range(0, n_jobs)]
    handles = []
    for i in range(0, n_jobs):
        red_patch = mpatches.Patch(color=color_job[i], label=i)
        handles.append(red_patch)
    plt.legend(handles=handles)
    plt.title(title)
    ax.set_yticklabels(label)
    ax.grid(True)
    title = ""
Пример #8
0
def plot_strand(strand, limits=None, cmap='viridis', **kwargs):
    """
    Plot hydrodynamic quantities at multiple timesteps

    This function takes all of the same keyword arguments as
    `~pydrad.visualize.plot_profile`.

    Parameters
    ----------
    strand : `~pydrad.parse.Strand`
    limits : `dict`, optional
        Axes limits for hydrodynamic quantities
    cmap : `str` or colormap instance
        The colormap to map the timestep index to

    See Also
    --------
    plot_profile
    """
    limits = {} if limits is None else limits
    plot_kwargs = kwargs.get('plot_kwargs', {})
    fig, axes = _setup_figure(strand[0], limits, **kwargs)
    colors = matplotlib.colors.LinearSegmentedColormap.from_list(
        '', plt.get_cmap(cmap).colors, N=len(strand))
    for i, p in enumerate(strand):
        plot_kwargs['color'] = colors(i)
        _ = _plot_profile(p, axes, **plot_kwargs)
Пример #9
0
    def get_kymo_plot(self, ax, lims=[-3, 3]):
        """
        """

        import matplotlib
        matplotlib.use('Qt4Agg')

        import matplotlib.pyplot as plt
        import matplotlib.colors as colors
        import matplotlib.cm as cmx

        dt = self.KD.dt
        duration = self.KD.duration
        anaphase = self.KD.params['t_A']
        times = np.arange(0, duration, dt)
        spbA = self.KD.spbL.traj
        spbB = self.KD.spbR.traj
        kts = self.KD.chromosomes

        ax.plot(times, spbA, color='black')
        ax.plot(times, spbB, color='black')

        if len(self.chrom_colors) == len(kts):
            colors = lambda x: self.chrom_colors[x]
        else:
            cm = plt.get_cmap('gist_rainbow')
            norm  = colors.Normalize(vmin=0, vmax=len(kts))
            sm = cmx.ScalarMappable(norm=norm, cmap=cm)
            colors = sm.to_rgba

        for i, kt in enumerate(kts):
            ax.plot(times, kt.cen_A.traj, color=colors(i), alpha=0.8)
            ax.plot(times, kt.cen_B.traj, color=colors(i), alpha=0.8)
            #ax.plot(times, (kt.cen_A.traj + kt.cen_B.traj)/2, color=colors(i), alpha=0.8)
        ax.grid()

        for lab in ax.xaxis.get_majorticklabels():
            lab.set_visible(False)

        ax.axvline(anaphase, color='black')
        if lims:
            ax.set_ylim(*lims)

        return ax
Пример #10
0
def draw(metrics, de_para="read"):
    """
    Draw these curves in one plot.
    :param metrics:
    :param de_para: dict
           The parameters of differential evolution.
    :return:
    """
    x, y, z = read_data()
    x_need_fit = x[:16]
    y_need_fit = y[:16]
    colors = cm.get_cmap("coolwarm", len(metrics))
    plt.bar(x_need_fit,
            y_need_fit,
            width=0.1,
            fc='black',
            label="original curve (bar)")
    plt.plot(x, y, color="lime", linestyle="-", label="original curve (1M)")
    i = 0
    save_coefficients = {}
    for metric in metrics:
        save_coefficients[metric] = {}
        if de_para == "read":
            params = analysis()
            fc = FitCurve(metric, **params[metric])
        else:
            fc = FitCurve(metric, **de_para)
        fc.fit(x_need_fit, y_need_fit)
        res = fc.new_v
        save_coefficients[metric] = res
        new_y = list(
            map(
                lambda elm: fc.exponential_function(elm, res[0], res[1], res[2]
                                                    ), x))
        plt.plot(x, new_y, color=colors(i), linestyle="-", label=metric)
        print(
            fc.metric, res,
            np.mean(
                np.array(
                    list(
                        map(
                            lambda elm: fc.exponential_function(
                                elm, res[0], res[1], res[2]), x_need_fit))) -
                y_need_fit), fc.score())
        i += 1
    if de_para == "read":  # Save into excel file
        sc = pd.DataFrame(save_coefficients)
        sc.to_excel(config.coefficients_path)
    plt.axhline(y=config.threshold, color='grey', linestyle='--')
    plt.title("The original and fit curves")
    plt.xlabel('report')
    plt.ylabel('all')
    plt.legend()
    plt.show()
Пример #11
0
def plotMatrix(ax, x, y, z, data, cmap="jet", cax=None, alpha=0.1):
    # plot a Matrix
    norm = matplotlib.colors.Normalize(vmin=data.min(), vmax=data.max())
    colors = lambda i, j, k: matplotlib.cm.ScalarMappable(
        norm=norm, cmap=cmap).to_rgba(data[i, j, k])
    for i, xi in enumerate(x):
        for j, yi in enumerate(y):
            for k, zi, in enumerate(z):
                plotCubeAt(pos=(xi, yi, zi),
                           c=colors(i, j, k),
                           alpha=alpha,
                           ax=ax)
Пример #12
0
def plot_matrix(ax, x, y, z, data, cmap='jet', cax=None, alpha=0.1):
  norm = matplotlib.colors.Normalize(vmin=data.min(), vmax=data.max())
  colors = lambda i,j,k : matplotlib.cm.ScalarMappable(norm=norm, cmap=cmap).to_rgba(data[i,j,k]) 
  for i, xi in enumerate(x):
    for j, yi in enumerate(y):
      for k, zi, in enumerate(z):
        plot_cube_at(ax, pos=(xi, yi, zi), c=colors(i,j,k), alpha=alpha)
  
  if cax !=None:
    cbar = matplotlib.colorbar.ColorbarBase(cax, cmap=cmap, norm=norm, orientation='vertical')
    cbar.set_ticks(np.unique(data) )
    # set the colorbar transparent as well
    cbar.solids.set(alpha=alpha)
Пример #13
0
 def _plot_heat3d(self):
     fig = plt.figure(figsize=(8, 6))
     ax = fig.gca(projection='3d')
     labels = [""] * len(self.acid_dict)
     for key in self.acid_dict:
         labels[self.acid_dict[key]] = key
     ax.set_xticks(np.arange(len(self.acid_dict)))
     ax.set_yticks(np.arange(len(self.acid_dict)))
     ax.set_zticks(np.arange(len(self.acid_dict)))
     ax.set_xticklabels(labels)
     ax.set_yticklabels(labels)
     ax.set_zticklabels(labels)
     ax.set_xlabel("condition 2 amino acids", fontdict={'size': 15})
     ax.set_ylabel("condition 1 amino acids", fontdict={'size': 15})
     ax.set_zlabel("actual amino acids", fontdict={'size': 15})
     colmap = matplotlib.cm.ScalarMappable(cmap="coolwarm")
     colmap.set_array([0, 1])
     # X, Y, Z = [], [], []
     # for i in range(len(self.acid_dict)):
     #         for j in range(len(self.acid_dict)):
     #             for k in range(len(self.acid_dict)):
     #                 X = X + [i] * len(self.acid_dict)
     #                 Y = Y + [j] * len(self.acid_dict)
     #                 Z = Z + [k] * len(self.acid_dict)
     # X = np.array(X)
     # Y = np.array(Y)
     # Z = np.array(Z)
     # D = [self.tensor[X[i]][Y[i]][Z[i]] for i in range(len(X))]
     # print(X.shape)
     # ax.scatter(X, Y, Z, marker='s', s=140,
     #            c=D , cmap='coolwarm', vmin=0, vmax=1, alpha=0.05);
     cb = fig.colorbar(colmap)
     norm = matplotlib.colors.Normalize(vmin=0, vmax=1)
     colors = lambda i, j, k: matplotlib.cm.ScalarMappable(
         norm=norm, cmap="coolwarm").to_rgba(self.tensor[i, j, k])
     for i in range(len(self.acid_dict)):
         for j in range(len(self.acid_dict)):
             for k in range(len(self.acid_dict)):
                 X, Y, Z = self._get_cube(k, j, i, 1)
                 ax.plot_surface(X,
                                 Y,
                                 Z,
                                 color=colors(i, j, k),
                                 rstride=1,
                                 cstride=1,
                                 alpha=0.03)
     plt.show()
Пример #14
0
def draw_points(img, points, alpha=0.5):
    """
    Given CT scan in numpy, draw points on the original img
    img: [D,H,W] or [D,H,W,3]
    points: [D, H, W] indicating the class each pixel belongs to
    """
    assert img.ndim == 3 or img.ndim == 4
    if img.ndim == 3:
        img = np.repeat(img[:, :, :, np.newaxis], 3, axis=3)

    num = int(points.max())
    colors = get_cmap(num)
    for i in range(1, num + 1):
        img[points == i] = img[points == i] * (1 - alpha) + np.array(
            list(colors(i))[:-1]) * alpha

    return img
Пример #15
0
def plot_strand(strand, limits=None, cmap='viridis', **kwargs):
    """
    Plot hydrodynamic quantities at multiple timesteps

    # Parameters
    strand (#pydrad.parse.Strand): Loop strand object
    limits (`dict`): Set axes limits for hydrodynamic quantities, optional
    cmap (`str`): The colormap to map the timestep index to
    plot_kwargs (`dict`): Any keyword arguments used matplotlib.plot, optional
    figsize (`tuple`): Width and height of figure, optional
    """
    limits = {} if limits is None else limits
    plot_kwargs = kwargs.get('plot_kwargs', {})
    fig, axes = _setup_figure(strand[0], limits, **kwargs)
    colors = matplotlib.colors.LinearSegmentedColormap.from_list(
        '', plt.get_cmap(cmap).colors, N=len(strand))
    for i, p in enumerate(strand):
        plot_kwargs['color'] = colors(i)
        _ = _plot_profile(p, axes, **plot_kwargs)
    plt.show()
def promoViz(t1,t2,by='id'):
    '''
    Plots promotional stats by metrics t1 and t2 (from promoByTransaction(t))
    if by=='id', displays results indexed by promotional_id
    if by=='media', displays results indexed by promo media_type
        NB: media types are odd, as some promos have in multiple media types
    (ti should be in ['roi','sales','cost','profit','sales per unit','profit per unit'])
    '''
    p1_by_id = promoByTransaction(t1)
    p2_by_id = promoByTransaction(t2)
    #if tallying by promo_id, don't need other lookups
    if by=='id':
        p1,p2 = p1_by_id,p2_by_id
    #if tallying by media type, need additional hash
    elif by=='media':
        #promo to media lookups
        promoID_to_media = getPromoLookups('media_type')
        #no promo needs a media type, too
        promoID_to_media[0] = 'none'
        
        #group the data by media_type
        media_type_size,p1,p2 = Counter(),Counter(),Counter()
        for k,v in p1_by_id.iteritems():
            p1[promoID_to_media[k]] += v
            media_type_size[promoID_to_media[k]] += 1
        for k,v in p2_by_id.iteritems():
            p2[promoID_to_media[k]] += v
            media_type_size[promoID_to_media[k]] += 1
    
    #plot
    fig = plt.figure()
    colors = get_cmap(len(p1.keys()))
    for i,p_id in enumerate(p1.keys()):
        plt.scatter(p1[p_id],p2[p_id],s=30*media_type_size[p_id],label=p_id,c=colors(i))
    #pyplot markup
    plt.suptitle('Performance of each promotional media type')
    plt.title
    plt.xlabel(t1+' promotional cost')
    plt.ylabel(t2+' promotional cost')
    plt.legend(loc='lower right',scatterpoints=1)
    plt.show()
Пример #17
0
    def make(self, environ):
        cm = environ.get_plot_collection_manager()
        history = environ.get_history(subset='harvest')
        optimiser = environ.get_optimiser()
        sref = 'Dark gray boxes mark reference solution.' \
            if self.show_reference else ''

        mpl_init(fontsize=self.font_size)
        cm.create_group_mpl(self,
                            self.draw_figures(history, optimiser),
                            title=u'Jointpar Plot',
                            section='solution',
                            feather_icon='crosshair',
                            description=u'''
Source problem parameter's scatter plots, to evaluate the resolution of source
parameters and possible trade-offs between pairs of model parameters.

A subset of model solutions (from harvest) is shown in two dimensions for all
possible parameter pairs as points. The point color indicates the misfit for
the model solution with cold colors (blue) for high misfit models and warm
colors (red) for low misfit models. The plot ranges are defined by the given
parameter bounds and shows the model space of the optimsation. %s''' % sref)
Пример #18
0
    y_max = max(max(y), y_max)

width = x_max - x_min
height = y_max - y_min
print(str([x_min, y_min, width, height]))
print("found: " + str(files))

masses = get_masses(files[0])
min_mass = min(masses)
for i in range(0, len(masses)):
    masses[i] = mass_multiplicator * masses[i] / min_mass

fig = plt.figure()
colors = get_cmap(N)

step = int(len(files) / N)
j = 0

for i in range(0, len(files), step):
    x, y = read_file(files[i])
    plt.scatter(x, y, c=colors(j), label=files[i],
                edgecolors='none')  #s=masses,
    print(str(colors(j)))
    j = j + 1

# axes = plt.gca()
# axes.set_xlim([x_min,x_max])
# axes.set_ylim([y_min,y_max])

plt.show()
Пример #19
0
    nb_scale = 3  # how many frame that we want to analyze
    threshold_face = 0.66
    threshold_decision = 0.6
    localPyramids = getLocalPyramids(image, clusters, nb_scale, window_length)

    #print clusters, len(clusters)
    for index, localImageList in enumerate(localPyramids):
        good = processLocalPyramid(localImageList, net, threshold_face,
                                   threshold_decision,
                                   window_length)  #'step' will be 1
        if not good:
            clusters[index] = -1

    #print clusters
    # getting all index which is not -1 (a local face)
    faces = []
    for index in xrange(len(clusters)):
        if clusters[index] != -1:
            faces.append(clusters[index])

    ##############
    #### PLOT ####
    ##############

    implot = plt.imshow(data, cmap=cm.Greys_r)
    colors = get_cmap(len(faces))
    for k in xrange(len(faces)):
        plt.scatter([pos[0] for pos in faces[k]], [pos[1] for pos in faces[k]],
                    c=colors(k))
    plt.show()
Пример #20
0
def plot_trained_models_history(trained_models_df,
                                validation_only=False,
                                labels=None) -> None:
    """
    Displays plots of (stacked) models training history.

    Parameters :
        - trained_models_df (DataFrame) :
            DataFrame with nrwos of trained models.
            The ["local_path"] column is used to locate the training history
            locally stored pickle files.
        - validation_only (bool) :
            whether or not to only plot curves drawn from the 'validation' dataset
            (as opposed to the default behavior consisting in
            also plotting curves from the 'development' dataset)
        - labels (list) :
            list of length 'trained_models_df.shape[0]' of the label
            to be used for each curve, respectively.

    Results :
        - N/A
    """

    fig = plt.figure(figsize=(14, 8))
    host1 = fig.add_subplot(2, 1, 1)
    host1.set_title('Training Loss')
    par1 = host1.twinx()
    host2 = fig.add_subplot(2, 1, 2)
    host2.set_title('Training Performance')
    par2 = host2.twinx()

    history_df = None

    colors_count = min(10, trained_models_df.shape[0] + 1)
    colors = plt.cm.get_cmap('gist_rainbow', (colors_count))  # cmap

    for i, trained_model in trained_models_df.iterrows():
        pickle_path = \
            os.path.join(trained_model["local_path"]
                         , "train_hstory_" + trained_model["timestamp"] + ".pickle")
        if not os.path.isfile(pickle_path):
            sys.stderr.write('Model history for model %s missing \n' %
                             trained_model["timestamp"])
        else:
            with open(pickle_path, 'rb') as f:
                history_reloaded = pd.DataFrame(pickle.load(f))

            color = colors(i % colors_count)
            idx_str = str(i) if labels is None else labels[i]
            if not validation_only:
                host1.plot(history_reloaded.index,
                           history_reloaded['loss'],
                           label='training ' + idx_str,
                           color=color,
                           linewidth=.7)
            host1.plot(history_reloaded.index,
                       history_reloaded['val_loss'],
                       label='validation ' + idx_str,
                       color=color,
                       linewidth=2)
            par1.plot(history_reloaded.index,
                      history_reloaded['lr'],
                      label='learning rate ' + idx_str,
                      color=color,
                      linestyle='dotted',
                      linewidth=.6)

            if not validation_only:
                host2.plot(history_reloaded.index,
                           history_reloaded['root_mean_squared_error'],
                           label='training ' + idx_str,
                           color=color,
                           linewidth=.7)
            host2.plot(history_reloaded.index,
                       history_reloaded['val_root_mean_squared_error'],
                       label='validation ' + idx_str,
                       color=color,
                       linewidth=2)
            par2.plot(history_reloaded.index,
                      history_reloaded['lr'],
                      label='learning rate ' + idx_str,
                      color=color,
                      linestyle='dotted',
                      linewidth=.6)

    host1.set_xlabel('Epoch')
    host1.set_ylabel('Loss')
    host1.set_ylim([0., min(150, host1.get_ylim()[1])])
    host1_legend = host1.legend(loc='upper right')
    par1.set_ylabel('Learning Rate')
    par1.legend(loc='upper right', bbox_to_anchor=(0., 0, 0.7, 1.))

    host2.set_xlabel('Epoch')
    host2.set_ylabel('RMSE')
    host2.set_ylim([(.5 if validation_only else .4),
                    min(1.,
                        host2.get_ylim()[1])])
    host2_legend = host2.legend(loc="upper right")
    par2.set_ylabel('Learning Rate')
    par2.legend(loc='upper right', bbox_to_anchor=(0., 0, 0.7, 1.))

    fig.tight_layout()
    plt.show()
    # deciding if there is a face or not in each local

    nb_scale=3 # how many frame that we want to analyze
    threshold_face = 0.66
    threshold_decision = 0.6
    localPyramids = getLocalPyramids(image, clusters,nb_scale,window_length)

    #print clusters, len(clusters)
    for index, localImageList in enumerate(localPyramids):
        good = processLocalPyramid(localImageList,net,threshold_face,threshold_decision,window_length) #'step' will be 1
        if not good:
            clusters[index]=-1

    #print clusters
    # getting all index which is not -1 (a local face)
    faces=[]
    for index in xrange(len(clusters)):
        if clusters[index] != -1:
            faces.append(clusters[index])

    ##############
    #### PLOT ####
    ##############

    implot = plt.imshow(data,cmap = cm.Greys_r)
    colors = get_cmap(len(faces))
    for k in xrange(len(faces)):
        plt.scatter([pos[0] for pos in faces[k]],[pos[1] for pos in faces[k]],c=colors(k))
    plt.show()

Пример #22
0
##############################################################################################################################################################################

from astropy.cosmology import FlatLambdaCDM,Planck13,Planck15,z_at_value
from astropy import units as u
from astropy.cosmology import LambdaCDM
cosmo = LambdaCDM(H0=70, Om0=0.3, Ode0=0.7)




##############################################################################################################################################################################
#Use numpy.loadtxt to import our data
wavelength, samp_1_abs, samp_2_abs = np.loadtxt('Absorbance_Data.csv', unpack=True, delimiter=',', skiprows=1)
# Plot the two sample absorbances, using previously generated colors
ax.plot(wavelength, samp_1_abs, linewidth=2, color=colors(0), label='Sample 1')
ax.plot(wavelength, samp_2_abs, linewidth=2, color=colors(1), label='Sample 2')
# Set the axis limits
ax.set_xlim(370, 930)
ax.set_ylim(-0.2, 2.2)
# Edit the major and minor tick locations
ax.xaxis.set_major_locator(mpl.ticker.MultipleLocator(100))
ax.xaxis.set_minor_locator(mpl.ticker.MultipleLocator(50))
ax.yaxis.set_major_locator(mpl.ticker.MultipleLocator(0.5))
ax.yaxis.set_minor_locator(mpl.ticker.MultipleLocator(0.25))
# Add the x and y-axis labels
ax.set_xlabel('Wavelength (nm)', labelpad=10)
ax.set_ylabel('Absorbance (O.D.)', labelpad=10)
# Add the x-axis label with λ for wavelength
ax.set_xlabel(r'$\mathregular{\lambda}$ (nm)', labelpad=10)
# Create new axes object by cloning the y-axis of the first plot
Пример #23
0
    speed = compressedSize / uncompressionTime

    toPlot_x.append(speed)
    toPlot_y.append(ratio)
    toPlot.append((speed, ratio))
    toPlot_legend.append(algo)

fig, ax = plt.subplots()


colors = get_cmap(len(toPlot_x))

plots = []
markers = ["x", "o"]
for i in range(len(toPlot_x)):
    plots.append(ax.scatter(toPlot_x[i], toPlot_y[i], c=colors(i), marker=markers[i % len(markers)]))

fig.legend(plots, toPlot_legend, scatterpoints=1, ncol=3, fontsize=8)

plt.xlabel("speed(Mbytes/s)")
plt.ylabel("ratio of compression")

plt.savefig("../../img/" + "ratioSpeedPlot" + ".png")

# imprime mapa de compressao com zoom nos dados que importam

label = []
for campo in ["CompressionTime(ms)"]:
    dataToPlot = []
    # ansci para 'A'
    i = 65
Пример #24
0
    '''Returns a function that maps each index in 0, 1, ... N-1 to a distinct 
    RGB color.'''
    color_norm  = colors.Normalize(vmin=0, vmax=N-1)
    scalar_map = cm.ScalarMappable(norm=color_norm, cmap='hsv') 
    def map_index_to_rgb_color(index):
        return scalar_map.to_rgba(index)
    return map_index_to_rgb_color

positions = [[42, 88], [42, 89], [43, 88], [43, 89], [43, 109], [43, 112], [43, 114], [44, 88], [44, 89], [44, 90], [45, 89], [45, 90], [46, 89], [46, 90], [46, 109], [46, 112], [46, 114], [46, 117], [47, 89], [47, 90], [48, 90], [48, 107], [48, 109], [48, 111], [48, 112], [48, 113], [48, 114], [48, 115], [48, 117], [49, 90], [50, 68], [50, 70], [50, 72], [50, 74], [50, 109], [50, 111], [50, 113], [50, 115], [51, 68], [51, 70], [51, 71], [51, 107], [51, 109], [51, 112], [51, 114], [51, 117], [52, 66], [52, 68], [52, 70], [52, 72], [52, 74], [52, 76], [52, 109], [52, 111], [52, 113], [52, 115], [52, 171], [52, 173], [52, 175], [52, 177], [53, 67], [53, 68], [53, 70], [53, 71], [53, 73], [53, 104], [53, 107], [53, 109], [53, 112], [53, 114], [53, 117], [54, 42], [54, 44], [54, 46], [54, 64], [54, 65], [54, 66], [54, 67], [54, 68], [54, 68], [54, 70], [54, 70], [54, 71], [54, 72], [54, 73], [54, 74], [54, 76], [54, 106], [54, 107], [54, 109], [54, 109], [54, 111], [54, 112], [54, 113], [54, 115], [54, 115], [54, 119], [54, 171], [54, 173], [54, 175], [54, 177], [56, 39], [56, 40], [56, 41], [56, 42], [56, 44], [56, 46], [56, 64], [56, 64], [56, 65], [56, 66], [56, 67], [56, 68], [56, 68], [56, 70], [56, 70], [56, 71], [56, 72], [56, 73], [56, 74], [56, 76], [56, 104], [56, 105], [56, 107], [56, 107], [56, 109], [56, 109], [56, 111], [56, 112], [56, 113], [56, 114], [56, 115], [56, 117], [56, 144], [56, 146], [56, 148], [56, 171], [56, 171], [56, 173], [56, 173], [56, 174], [56, 175], [56, 177], [57, 37], [57, 39], [57, 40], [57, 42], [57, 64], [57, 65], [57, 67], [57, 68], [57, 70], [57, 71], [57, 73], [57, 106], [57, 109], [57, 112], [57, 115], [57, 119], [57, 168], [57, 170], [57, 171], [57, 173], [57, 174], [58, 41], [58, 42], [58, 44], [58, 46], [58, 48], [58, 64], [58, 66], [58, 68], [58, 70], [58, 72], [58, 74], [58, 76], [58, 104], [58, 105], [58, 107], [58, 107], [58, 109], [58, 109], [58, 111], [58, 112], [58, 113], [58, 114], [58, 115], [58, 117], [58, 142], [58, 144], [58, 146], [58, 148], [58, 148], [58, 150], [58, 169], [58, 171], [58, 173], [58, 175], [58, 177], [59, 37], [59, 39], [59, 40], [59, 42], [59, 64], [59, 65], [59, 67], [59, 68], [59, 70], [59, 71], [59, 168], [59, 170], [59, 171], [59, 173], [60, 37], [60, 39], [60, 40], [60, 41], [60, 42], [60, 42], [60, 44], [60, 46], [60, 64], [60, 65], [60, 66], [60, 67], [60, 68], [60, 68], [60, 70], [60, 70], [60, 71], [60, 72], [60, 74], [60, 105], [60, 107], [60, 109], [60, 111], [60, 113], [60, 115], [60, 142], [60, 144], [60, 146], [60, 148], [60, 150], [60, 168], [60, 170], [60, 170], [60, 171], [60, 171], [60, 173], [60, 173], [60, 175], [60, 177], [61, 104], [61, 106], [61, 107], [61, 109], [61, 109], [61, 112], [61, 112], [61, 114], [61, 115], [61, 117], [61, 119], [61, 148], [61, 170], [62, 37], [62, 39], [62, 40], [62, 41], [62, 42], [62, 42], [62, 43], [62, 44], [62, 46], [62, 67], [62, 68], [62, 68], [62, 70], [62, 70], [62, 105], [62, 107], [62, 109], [62, 111], [62, 113], [62, 115], [62, 142], [62, 144], [62, 146], [62, 148], [62, 167], [62, 170], [62, 171], [62, 171], [62, 173], [62, 175], [62, 177], [63, 104], [63, 107], [63, 109], [63, 112], [63, 114], [63, 117], [63, 148], [63, 170], [64, 39], [64, 40], [64, 41], [64, 42], [64, 42], [64, 44], [64, 106], [64, 107], [64, 109], [64, 109], [64, 111], [64, 112], [64, 113], [64, 115], [64, 119], [64, 142], [64, 144], [64, 146], [64, 173], [64, 175], [65, 39], [65, 40], [65, 42], [65, 90], [65, 91], [65, 92], [65, 104], [65, 107], [65, 109], [65, 112], [65, 114], [66, 41], [66, 42], [66, 44], [66, 90], [66, 91], [66, 91], [66, 92], [66, 92], [66, 144], [66, 146], [67, 40], [67, 89], [67, 90], [67, 91], [67, 91], [67, 92], [67, 92], [67, 106], [67, 109], [67, 112], [67, 115], [67, 119], [68, 89], [68, 90], [68, 91], [68, 91], [68, 92], [68, 92], [68, 107], [68, 109], [68, 110], [68, 112], [68, 114], [68, 114], [68, 118], [68, 122], [69, 89], [69, 90], [69, 91], [69, 92], [70, 54], [70, 57], [70, 88], [70, 89], [70, 90], [70, 91], [70, 91], [70, 92], [70, 106], [70, 109], [70, 109], [70, 112], [70, 112], [70, 115], [70, 119], [71, 88], [71, 89], [71, 90], [71, 91], [72, 88], [72, 89], [72, 90], [72, 91], [72, 110], [72, 114], [72, 118], [72, 122], [73, 54], [73, 57], [73, 61], [73, 64], [73, 88], [73, 89], [73, 90], [73, 109], [73, 109], [73, 112], [73, 112], [73, 115], [73, 152], [73, 155], [75, 184], [76, 54], [76, 57], [76, 61], [76, 64], [76, 109], [76, 110], [76, 112], [76, 114], [76, 115], [76, 118], [76, 122], [76, 152], [76, 155], [79, 54], [79, 57], [79, 61], [79, 64], [79, 109], [79, 112], [79, 115], [79, 152], [79, 155], [80, 110], [80, 114], [80, 118], [82, 54], [82, 57], [82, 61], [82, 109], [82, 112], [82, 152], [82, 155], [83, 68], [83, 110], [83, 114], [83, 118], [85, 54], [85, 57], [85, 109], [85, 112], [85, 152], [85, 155], [87, 109], [87, 110], [87, 112], [87, 114], [88, 54], [88, 57], [88, 109], [88, 112], [88, 152], [88, 155], [90, 109], [90, 112], [91, 54], [91, 57], [91, 109], [91, 112], [91, 114], [91, 152], [91, 155], [92, 109], [92, 112], [94, 54], [94, 57], [94, 109], [94, 112], [94, 152], [94, 155], [95, 68], [95, 107], [95, 109], [95, 112], [95, 114], [95, 114], [97, 54], [97, 57], [97, 107], [97, 109], [97, 109], [97, 109], [97, 111], [97, 112], [97, 112], [97, 114], [97, 152], [97, 155], [99, 68], [99, 107], [99, 109], [99, 111], [99, 113], [99, 114], [100, 107], [100, 109], [100, 109], [100, 112], [100, 112], [100, 152], [100, 155], [101, 107], [101, 109], [101, 111], [101, 113], [101, 149], [101, 151], [101, 153], [102, 107], [102, 109], [102, 112], [102, 114], [103, 107], [103, 109], [103, 109], [103, 111], [103, 112], [103, 113], [103, 149], [103, 151], [103, 152], [103, 153], [103, 154], [103, 155], [104, 107], [104, 109], [104, 151], [104, 153], [105, 56], [105, 57], [105, 107], [105, 109], [105, 111], [105, 166], [105, 167], [105, 168], [106, 75], [106, 109], [106, 114], [106, 152], [106, 155], [106, 165], [106, 166], [106, 167], [106, 168], [106, 170], [106, 178], [106, 180], [107, 74], [107, 75], [107, 166], [107, 167], [107, 168], [109, 109], [109, 152], [109, 155], [110, 114], [112, 151], [112, 152], [112, 153], [112, 155], [114, 114], [114, 119], [114, 151], [114, 153], [115, 152], [117, 151], [118, 110], [118, 114], [119, 114], [119, 119], [119, 123], [122, 109], [122, 110], [122, 112], [122, 114], [122, 118], [123, 114], [123, 119], [123, 123], [125, 109], [125, 110], [125, 112], [125, 114], [125, 118], [125, 122], [128, 109], [128, 112], [128, 114], [128, 119], [128, 123], [129, 110], [129, 114], [129, 118], [129, 122], [131, 109], [131, 112], [131, 115], [133, 106], [133, 110], [133, 114], [133, 114], [133, 118], [133, 119], [133, 122], [133, 123], [134, 106], [134, 109], [134, 112], [134, 115], [134, 119], [136, 112], [137, 106], [137, 106], [137, 109], [137, 110], [137, 112], [137, 114], [137, 115], [137, 118], [137, 119], [137, 122], [138, 109], [138, 114], [138, 119], [138, 123], [139, 107], [139, 109], [139, 112], [139, 114], [140, 106], [140, 109], [140, 112], [140, 115], [140, 119], [141, 106], [141, 107], [141, 109], [141, 110], [141, 112], [141, 114], [141, 114], [141, 118], [141, 122], [141, 196], [143, 106], [143, 109], [143, 109], [143, 112], [143, 114], [143, 115], [143, 119], [143, 119], [143, 123], [144, 70], [144, 104], [144, 106], [144, 107], [144, 109], [144, 110], [144, 112], [144, 114], [144, 114], [144, 117], [144, 118], [144, 122], [146, 68], [146, 70], [146, 72], [146, 103], [146, 104], [146, 106], [146, 107], [146, 109], [146, 109], [146, 112], [146, 112], [146, 114], [146, 115], [146, 117], [146, 119], [146, 171], [146, 173], [146, 175], [146, 177], [147, 109], [147, 114], [147, 119], [147, 123], [147, 171], [148, 66], [148, 67], [148, 68], [148, 68], [148, 70], [148, 70], [148, 72], [148, 74], [148, 104], [148, 106], [148, 107], [148, 109], [148, 110], [148, 112], [148, 114], [148, 114], [148, 117], [148, 118], [148, 122], [148, 169], [148, 171], [148, 171], [148, 173], [148, 173], [148, 174], [148, 175], [148, 176], [148, 177], [148, 178], [149, 65], [149, 67], [149, 68], [149, 70], [149, 103], [149, 106], [149, 109], [149, 112], [149, 115], [149, 119], [149, 171], [149, 173], [149, 174], [149, 176], [149, 178], [150, 39], [150, 41], [150, 42], [150, 44], [150, 66], [150, 68], [150, 70], [150, 72], [150, 74], [150, 144], [150, 146], [150, 148], [150, 150], [150, 169], [150, 171], [150, 173], [150, 175], [150, 177], [151, 43], [151, 64], [151, 65], [151, 67], [151, 68], [151, 70], [151, 104], [151, 107], [151, 109], [151, 112], [151, 114], [151, 117], [151, 143], [151, 170], [151, 171], [151, 173], [151, 174], [151, 176], [151, 178], [152, 39], [152, 41], [152, 42], [152, 44], [152, 66], [152, 68], [152, 70], [152, 72], [152, 74], [152, 103], [152, 106], [152, 106], [152, 109], [152, 109], [152, 110], [152, 112], [152, 114], [152, 114], [152, 115], [152, 118], [152, 119], [152, 119], [152, 122], [152, 123], [152, 144], [152, 146], [152, 148], [152, 150], [152, 152], [152, 167], [152, 169], [152, 171], [152, 173], [152, 175], [152, 177], [153, 43], [153, 46], [153, 64], [153, 65], [153, 65], [153, 67], [153, 68], [153, 104], [153, 107], [153, 109], [153, 112], [153, 114], [153, 142], [153, 143], [153, 145], [153, 151], [153, 168], [153, 170], [153, 171], [153, 173], [153, 174], [153, 176], [153, 178], [153, 196], [154, 37], [154, 39], [154, 41], [154, 42], [154, 44], [154, 64], [154, 65], [154, 66], [154, 67], [154, 68], [154, 68], [154, 70], [154, 72], [154, 74], [154, 142], [154, 143], [154, 144], [154, 145], [154, 146], [154, 148], [154, 150], [154, 152], [154, 168], [154, 169], [154, 170], [154, 171], [154, 171], [154, 173], [154, 173], [154, 174], [154, 175], [154, 176], [154, 177], [154, 196], [155, 62], [155, 65], [155, 103], [155, 106], [155, 109], [155, 112], [155, 115], [156, 37], [156, 39], [156, 41], [156, 42], [156, 43], [156, 44], [156, 62], [156, 64], [156, 65], [156, 65], [156, 67], [156, 68], [156, 70], [156, 72], [156, 104], [156, 106], [156, 107], [156, 109], [156, 110], [156, 112], [156, 114], [156, 118], [156, 122], [156, 142], [156, 143], [156, 144], [156, 145], [156, 146], [156, 146], [156, 148], [156, 150], [156, 151], [156, 169], [156, 170], [156, 171], [156, 171], [156, 173], [156, 173], [156, 174], [156, 175], [156, 176], [156, 177], [157, 62], [157, 65], [157, 109], [157, 114], [157, 119], [157, 123], [157, 142], [157, 143], [157, 145], [157, 146], [157, 171], [157, 173], [157, 174], [158, 39], [158, 41], [158, 42], [158, 62], [158, 68], [158, 70], [158, 72], [158, 103], [158, 104], [158, 106], [158, 107], [158, 109], [158, 109], [158, 112], [158, 112], [158, 115], [158, 144], [158, 146], [158, 148], [158, 150], [158, 151], [158, 171], [158, 173], [158, 175], [159, 142], [159, 143], [159, 145], [159, 146], [160, 39], [160, 41], [160, 106], [160, 110], [160, 114], [160, 118], [160, 122], [160, 143], [160, 144], [160, 145], [160, 146], [160, 146], [160, 148], [161, 104], [161, 106], [161, 107], [161, 109], [161, 109], [161, 112], [161, 115], [161, 196], [161, 197], [162, 114], [162, 119], [162, 123], [162, 143], [162, 146], [162, 196], [162, 197], [163, 104], [163, 107], [163, 109], [163, 195], [163, 196], [163, 197], [164, 54], [164, 106], [164, 106], [164, 109], [164, 110], [164, 112], [164, 114], [164, 115], [164, 118], [164, 122], [164, 155], [164, 195], [164, 196], [164, 197], [165, 195], [165, 196], [165, 197], [166, 114], [166, 119], [166, 123], [166, 194], [166, 195], [166, 196], [166, 197], [167, 54], [167, 57], [167, 61], [167, 106], [167, 106], [167, 109], [167, 110], [167, 112], [167, 114], [167, 115], [167, 118], [167, 122], [167, 155], [167, 194], [167, 195], [167, 196], [167, 197], [168, 194], [168, 195], [168, 196], [168, 197], [169, 194], [169, 195], [169, 196], [170, 54], [170, 57], [170, 61], [170, 106], [170, 109], [170, 112], [170, 115], [170, 152], [170, 155], [170, 195], [171, 106], [171, 110], [171, 114], [171, 114], [171, 118], [171, 119], [173, 54], [173, 57], [173, 106], [173, 109], [173, 112], [173, 115], [173, 152], [173, 155], [175, 110], [175, 114], [175, 118], [176, 114], [176, 119], [177, 54], [177, 106], [177, 109], [177, 112], [177, 152], [177, 155], [179, 110], [179, 114], [180, 54], [180, 106], [180, 109], [180, 112], [180, 155], [181, 114], [183, 54], [183, 106], [183, 109], [183, 110], [183, 112], [183, 114], [183, 155], [185, 43], [185, 46], [185, 114], [186, 54], [186, 106], [186, 109], [186, 110], [186, 112], [186, 114], [186, 155], [187, 43], [187, 46], [187, 107], [187, 109], [187, 112], [189, 54], [189, 106], [189, 109], [189, 112], [189, 155], [190, 46], [190, 104], [190, 107], [190, 109], [190, 110], [190, 112], [190, 114], [190, 114], [192, 54], [192, 102], [192, 104], [192, 106], [192, 107], [192, 109], [192, 109], [192, 112], [192, 112], [192, 155], [193, 109], [194, 110], [194, 114], [195, 102], [195, 104], [195, 107], [195, 107], [195, 109], [195, 109], [195, 109], [195, 114], [197, 102], [197, 104], [197, 105], [197, 107], [197, 107], [197, 109], [197, 109], [198, 109], [198, 110], [198, 114], [198, 155], [199, 107], [199, 109], [200, 104], [200, 107], [200, 114], [200, 161], [200, 162], [200, 176], [200, 177], [200, 178], [201, 155], [201, 162], [201, 177], [201, 178], [202, 46], [202, 70], [202, 71], [202, 72], [202, 73], [202, 74], [202, 75], [202, 76], [202, 114], [202, 174], [202, 175], [202, 176], [202, 177], [202, 178], [202, 179], [202, 180], [203, 72], [203, 73], [203, 74], [203, 75], [203, 76], [203, 77], [203, 175], [203, 176], [203, 177], [203, 178], [203, 179], [203, 180], [204, 155], [205, 43], [205, 46], [205, 48], [205, 114], [205, 114], [205, 153], [207, 43], [207, 46], [207, 151], [207, 153], [207, 155], [209, 43], [209, 46], [209, 110], [209, 114], [209, 151], [209, 153], [213, 110], [213, 114], [216, 109], [217, 110], [217, 114], [217, 118], [219, 109], [219, 112], [221, 110], [221, 114], [221, 118], [221, 122], [222, 109], [222, 112], [225, 106], [225, 109], [225, 110], [225, 112], [225, 114], [225, 115], [225, 118], [225, 122], [228, 106], [228, 109], [228, 112], [228, 115], [228, 119], [231, 106], [231, 109], [231, 109], [231, 112], [231, 112], [231, 115], [231, 119], [234, 106], [234, 107], [234, 109], [234, 109], [234, 112], [234, 112], [234, 114], [234, 115], [234, 119], [236, 107], [236, 109], [236, 112], [236, 114], [236, 117], [238, 103], [238, 106], [238, 109], [238, 112], [238, 115], [238, 119], [239, 104], [239, 107], [239, 109], [239, 112], [239, 114], [239, 117], [240, 68], [240, 70], [240, 72], [240, 171], [240, 173], [240, 173], [240, 175], [240, 177], [241, 103], [241, 104], [241, 106], [241, 107], [241, 109], [241, 109], [241, 112], [241, 112], [241, 114], [241, 115], [241, 117], [241, 119], [242, 66], [242, 67], [242, 68], [242, 70], [242, 72], [242, 169], [242, 171], [242, 171], [242, 173], [242, 173], [242, 174], [242, 175], [242, 176], [242, 177], [242, 178], [243, 64], [243, 65], [243, 67], [243, 68], [243, 170], [243, 171], [243, 173], [243, 174], [243, 176], [243, 178], [244, 39], [244, 41], [244, 42], [244, 43], [244, 66], [244, 68], [244, 70], [244, 72], [244, 74], [244, 104], [244, 107], [244, 109], [244, 112], [244, 114], [244, 117], [244, 144], [244, 146], [244, 148], [244, 150], [244, 167], [244, 169], [244, 171], [244, 173], [244, 175], [244, 177], [245, 64], [245, 65], [245, 67], [245, 68], [245, 168], [245, 170], [245, 171], [245, 173], [245, 174], [245, 176], [245, 178], [246, 37], [246, 39], [246, 41], [246, 42], [246, 43], [246, 44], [246, 46], [246, 62], [246, 64], [246, 65], [246, 66], [246, 67], [246, 68], [246, 68], [246, 70], [246, 72], [246, 74], [246, 104], [246, 107], [246, 109], [246, 112], [246, 114], [246, 143], [246, 144], [246, 146], [246, 148], [246, 150], [246, 152], [246, 167], [246, 168], [246, 169], [246, 170], [246, 171], [246, 171], [246, 173], [246, 173], [246, 174], [246, 175], [246, 176], [246, 177], [248, 37], [248, 39], [248, 41], [248, 42], [248, 44], [248, 62], [248, 63], [248, 64], [248, 65], [248, 66], [248, 67], [248, 68], [248, 68], [248, 70], [248, 72], [248, 142], [248, 143], [248, 144], [248, 145], [248, 146], [248, 148], [248, 150], [248, 152], [248, 168], [248, 169], [248, 170], [248, 171], [248, 171], [248, 173], [248, 173], [248, 174], [248, 175], [248, 176], [248, 177], [249, 37], [249, 39], [249, 41], [249, 42], [249, 43], [249, 62], [249, 64], [249, 65], [249, 66], [249, 67], [249, 68], [249, 68], [249, 70], [249, 72], [249, 104], [249, 107], [249, 109], [249, 112], [249, 114], [249, 142], [249, 143], [249, 144], [249, 145], [249, 146], [249, 148], [249, 150], [249, 168], [249, 169], [249, 170], [249, 171], [249, 171], [249, 173], [249, 173], [249, 174], [249, 175], [249, 176], [249, 177], [250, 63], [251, 37], [251, 39], [251, 41], [251, 42], [251, 43], [251, 62], [251, 63], [251, 64], [251, 65], [251, 67], [251, 68], [251, 70], [251, 104], [251, 107], [251, 109], [251, 112], [251, 142], [251, 143], [251, 144], [251, 145], [251, 146], [251, 148], [251, 170], [251, 171], [251, 173], [251, 173], [251, 174], [252, 63], [253, 37], [253, 39], [253, 41], [253, 65], [253, 104], [253, 107], [253, 109], [253, 143], [253, 144], [253, 145], [253, 146], [253, 148], [253, 171], [255, 39], [255, 196], [256, 195], [256, 196], [256, 197], [257, 89], [257, 195], [257, 196], [257, 197], [258, 87], [258, 88], [258, 89], [258, 194], [258, 195], [258, 196], [258, 197], [259, 87], [259, 88], [259, 89], [259, 194], [259, 195], [259, 196], [259, 197], [260, 87], [260, 88], [260, 89], [260, 194], [260, 195], [260, 196], [260, 197], [261, 87], [261, 88], [261, 89], [261, 194], [261, 195], [261, 196], [261, 197], [262, 87], [262, 88], [262, 194], [262, 195], [262, 196]]

db =  DBSCAN(eps=3, min_samples=15).fit(positions)

clusters = []

for k in np.unique(db.labels_):
    clusters.append([])
    members = np.where(db.labels_ == k)[0]
    print members
    if k == -1:
        print("outliers:")
    else:
        print("cluster %d:" % k)
        clusters[k] = [positions[i] for i in members]

colors = get_cmap(len(clusters))
for k in xrange(len(clusters)):
        plt.scatter([pos[0] for pos in clusters[k]],[pos[1] for pos in clusters[k]],c=colors(k))
plt.show()
print clusters