python类grid()的实例源码

4(improved-10) 1.py 文件源码 项目:computational_physics_N2014301020117 作者: yukangnineteen 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def show_results(self):
        pl.plot(self.t, self.n_A, 'b--', label='Number of Nuclei A')
        pl.plot(self.t, self.n_B, 'b', label='Number of Nuclei B')
        pl.plot(self.t, self.n_A_true, 'g--', label='True Number of Nuclei A')
        pl.plot(self.t, self.n_B_true, 'g', label='True Number of Nuclei B')
        pl.title('Double Decay Probelm-Approximation Compared with True')
        pl.xlim(0.0, 2.5)
        pl.ylim(0.0, 100.0)
        pl.xlabel('time ($s$)')
        pl.ylabel('Number of Nuclei')
        pl.legend(loc='best', shadow=True)
        pl.grid(True)
ui.py 文件源码 项目:autoxd 作者: nessessary 项目源码 文件源码 阅读 45 收藏 0 点赞 0 评论 0
def ShowZZ(pl, zz, title=''):
    pl.figure
    pl.grid()
    if title != '':
        pl.title(title)
    DrawZZ(pl, zz, c='b')
    pl.show()
    pl.close()
publish.py 文件源码 项目:autoxd 作者: nessessary 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def grid(self, *args, **kwargs):
        pl.grid(*args, **kwargs)
model_runner.py 文件源码 项目:plasma 作者: jnkh 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def plot_losses(conf,losses_list,builder,name=''):
    unique_id = builder.get_unique_id()
    savedir = 'losses'
    if not os.path.exists(savedir):
        os.makedirs(savedir)

    save_path = os.path.join(savedir,'{}_loss_{}.png'.format(name,unique_id))
    pl.figure()
    for losses in losses_list:
        pl.semilogy(losses)
    pl.xlabel('Epoch')
    pl.ylabel('Loss')
    pl.grid()
    pl.savefig(save_path)
pyroc.py 文件源码 项目:bokeh_roc_slider 作者: brianray 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def plot_multiple_roc(rocList,title='',labels=None, include_baseline=False, equal_aspect=True):
    """ Plots multiple ROC curves on the same chart.
        Parameters:
            rocList: the list of ROCData objects
            title: The tile of the chart
            labels: The labels of each ROC curve
            include_baseline: if it's  True include the random baseline
            equal_aspect: keep equal aspect for all roc curves
    """
    pylab.clf()
    pylab.ylim((0,1))
    pylab.xlim((0,1))
    pylab.xticks(pylab.arange(0,1.1,.1))
    pylab.yticks(pylab.arange(0,1.1,.1))
    pylab.grid(True)
    if equal_aspect:
        cax = pylab.gca()
        cax.set_aspect('equal')
    pylab.xlabel("1 - Specificity")
    pylab.ylabel("Sensitivity")
    pylab.title(title)
    if not labels:
        labels = [ '' for x in rocList]
    _remove_duplicate_styles(rocList)
    for ix, r in enumerate(rocList):
        pylab.plot([x[0] for x in r.derived_points], [y[1] for y in r.derived_points], r.linestyle, linewidth=1, label=labels[ix])
    if include_baseline:
        pylab.plot([0.0,1.0], [0.0, 1.0], 'k-', label= 'random')
    if labels:
        pylab.legend(loc='lower right')

    pylab.show()
h1ds.py 文件源码 项目:PyFusionGUI 作者: SyntaxVoid 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def plot(self):
        import pylab as pl
        pl.plot(self.dim, self.signal)
        pl.xlabel(self.dim_units)
        pl.ylabel(self.signal_units)
        pl.grid(True)
        pl.show()
coverage.py 文件源码 项目:sequana 作者: sequana 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def get_required_coverage(self, M=0.01):
        """Return the required coverage to ensure the genome is covered

        A general question is what should be the coverage to make sure
        that e.g. E=99% of the genome is covered by at least a read.

        The answer is:

        .. math:: \log^{-1/(E-1)}

        This equation is correct but have a limitation due to floating precision. 
        If one provides E=0.99, the answer is 4.6 but we are limited to a
        maximum coverage of about 36 when one provides E=0.9999999999999999
        after which E is rounded to 1 on most computers. Besides, it is no
        convenient to enter all those numbers. A scientific notation would be better but
        requires to work with :math:`M=1-E` instead of :math:`E`.

        .. math:: \log^{-1/ - M}

        So instead of asking the question what is the
        requested fold coverage to have 99% of the genome covered, we ask the question what
        is the requested fold coverage to have 1% of the genome not covered.
        This allows us to use :math:`M` values as low as 1e-300 that is a fold coverage 
        as high as 690.


        :param float M: this is the fraction of the genome not covered by
            any reads (e.g. 0.01 for 1%). See note above.
        :return: the required fold coverage

        .. plot::

            import pylab
            from sequana import Coverage
            cover = Coverage()
            misses = np.array([1e-1, 1e-2, 1e-3, 1e-4,1e-5,1e-6])
            required_coverage = cover.get_required_coverage(misses)
            pylab.semilogx(misses, required_coverage, 'o-')
            pylab.ylabel("Required coverage", fontsize=16)
            pylab.xlabel("Uncovered genome", fontsize=16)
            pylab.grid()

        # The inverse equation is required fold coverage = [log(-1/(E - 1))]
        """
        # What should be the fold coverage to have 99% of the genome sequenced ?
        # It is the same question as equating 1-e^{-(NL/G}) == 0.99, we need NL/G = 4.6
        if isinstance(M, float) or isinstance(M, int):
            assert M < 1
            assert M >=0
        else:
            M = np.array(M)
        # Here we do not use log(-1/(E-1)) but log(-1/(1-E-1)) to allow
        # for using float down to 1e-300 since 0.999999999999999 == 1
        return np.log(-1/(-M))
helper.py 文件源码 项目:svm-street-detector 作者: morris-frank 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
helper.py 文件源码 项目:VOCSeg 作者: lxh-123 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
helper.py 文件源码 项目:VOCSeg 作者: lxh-123 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
helper.py 文件源码 项目:KittiSeg 作者: MarvinTeichmann 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
helper.py 文件源码 项目:KittiSeg 作者: MarvinTeichmann 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
helper.py 文件源码 项目:KittiSeg 作者: MarvinTeichmann 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def plotPrecisionRecall(precision, recall, outFileName, Fig=None, drawCol=1, textLabel = None, title = None, fontsize1 = 24, fontsize2 = 20, linewidth = 3):
    '''

    :param precision:
    :param recall:
    :param outFileName:
    :param Fig:
    :param drawCol:
    :param textLabel:
    :param fontsize1:
    :param fontsize2:
    :param linewidth:
    '''

    clearFig = False  

    if Fig == None:
        Fig = pylab.figure()
        clearFig = True

    #tableString = 'Algo avgprec Fmax prec recall accuracy fpr Q(TonITS)\n'
    linecol = ['g','m','b','c']
    #if we are evaluating SP, then BL is available
    #sectionName = 'Evaluation_'+tag+'PxProb'
    #fullEvalFile = os.path.join(eval_dir,evalName)
    #Precision,Recall,evalString = readEvaluation(fullEvalFile,sectionName,AlgoLabel)

    pylab.plot(100*recall, 100*precision, linewidth=linewidth, color=linecol[drawCol], label=textLabel)


    #writing out PrecRecall curves as graphic
    setFigLinesBW(Fig)
    if textLabel!= None:
        pylab.legend(loc='lower left',prop={'size':fontsize2})

    if title!= None:
        pylab.title(title, fontsize=fontsize1)

    #pylab.title(title,fontsize=24)
    pylab.ylabel('PRECISION [%]',fontsize=fontsize1)
    pylab.xlabel('RECALL [%]',fontsize=fontsize1)

    pylab.xlim(0,100)
    pylab.xticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.ylim(0,100)
    pylab.yticks( [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
                      ('0','','20','','40','','60','','80','','100'), fontsize=fontsize2 )
    pylab.grid(True)

    # 
    if type(outFileName) != list:
        pylab.savefig( outFileName )
    else:
        for outFn in outFileName:
            pylab.savefig( outFn )
    if clearFig:
        pylab.close()
        Fig.clear()
plot.py 文件源码 项目:Kionix-IoT-Evaluation-Kit 作者: RohmSemiconductor 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def doit(csvfile):
    sensordata=[]
    timestamplist=[]
    if 1:#with open(fname, 'rb') as csvfile:

        for t in range(args.skip_lines): csvfile.readline()

        reader = csv.reader(csvfile, delimiter=args.delimiter)
        for a in reader:

            if a==[]: continue # empty line            
            try:
                values = [float(t.replace(',','.')) for t in a if t !='']
            except Exception,e:
                print a, e
                continue

            if args.columns:
                values = [values[t] for t in args.columns]

            if args.timestamps:
                sensordata.append(values[1:])
                timestamplist.append(values[0])

            else: 
                sensordata.append(values)


        if args.histogram:
            import matplotlib.mlab as mlab
            mu = mlab.np.average(sensordata)
            sigma = max(abs(mlab.np.max(sensordata)- mu), abs(mlab.np.min(sensordata)- mu))

            # the histogram of the data
            n, bins, patches = pylab.hist(mlab.np.array(sensordata), 100, normed=True, facecolor='green', alpha=0.75)

            pylab.grid()
            pylab.show()

        if args.output_file_name:
            outfile = open(args.output_file_name,'w')
            for line in sensordata:
                outfile.write(args.output_delimiter.join([args.output_formatter % round(t*args.output_multiplier) for t in line])+'\n')
        else:

            if timestamplist!=[]: # data with timestamp
                pylab.plot(timestamplist, sensordata, args.tick_mark)
                pylab.xlabel('time')
            else:
                pylab.plot(sensordata, args.tick_mark)
                pylab.xlabel('sample #')

            pylab.title(csvfile.name)

            if args.legend:
                pylab.legend(args.legend)

            pylab.grid()
            pylab.show()
neuron.py 文件源码 项目:myhdl-experiments 作者: CodeReclaimers 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def iz_test_bench(a, b, c, d, dt, Fshift):
    max_val = 1 << (Fshift + 7)

    I = Signal(intbv(0, min=-max_val, max=max_val))
    output = Signal(bool(0))

    clk = Signal(bool(0))
    reset = ResetSignal(1, active=0, async=True)

    neuron_instance = neuron_module(clk, reset, I, output, a, b, c, d, dt, Fshift)

    @always(delay(50))
    def clkgen():
        clk.next = not clk

    @instance
    def stimulus():
        I.next = 0
        yield delay(10000)
        I.next = to_fixed(10.0, Fshift)
        yield delay(100000)
        I.next = 0
        yield delay(10000)

        pylab.figure(1)
        pylab.subplot(311)
        pylab.title("MyHDL Izhikevitch neuron (chattering)")
        pylab.plot(t_values, v_values, label="v")
        pylab.ylabel('membrane potential (mv)')
        pylab.grid()
        pylab.subplot(312)
        pylab.plot(t_values, u_values, label="u")
        pylab.ylabel("recovery variable")
        pylab.grid()
        pylab.subplot(313)
        pylab.plot(t_values, I_values, label="I")
        pylab.grid()
        pylab.ylabel("input current")
        pylab.xlabel("time (usec)")
        pylab.show()

        raise StopSimulation

    return clkgen, stimulus, neuron_instance


# Uncomment definitions of a, b, c, d to choose different neuron types.

# Regular spiking
#a, b, c, d = 0.02, 0.2, -65.0, 8.0

# Fast spiking
#a, b, c, d = 0.1, 0.2, -65.0, 2.0

#intrinsically bursting
#a, b, c, d =0.02, 0.2, -55.0, 4.0

# chattering
data_visualization.py 文件源码 项目:Oedipus 作者: tum-i22 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def plotReductionGraph(dataSamples, dataLabels, classNames, dimension=2, graphTitle="Test Graph", filename="reduction.pdf"):
    """ Plots data sample visualization graphs """
    try:
        timestamp = int(time.time())
        colors = ['DarkRed', 'DarkGreen', 'DarkBlue', 'DarkOrange', 'DarkMagenta', 'DarkCyan', 'Gray', 'Black']
        randomColor = lambda: random.randint(0,255)
        markers = ['*', 'o', 'v', '^', 's', 'd', 'D', 'p', 'h', 'H', '<', '>', '.', ',', '|', '_']

        fig = P.figure(figsize=(8,5))
        if dimension == 3:
            ax = fig.add_subplot(111, projection='3d')
        P.title(graphTitle, fontname='monospace')
        if dimension == 2:
            P.xlabel('x1', fontsize=12, fontname='monospace')
            P.ylabel('x2', fontsize=12, fontname='monospace')
        else:
            ax.set_xlabel('x1', fontsize=12, fontname='monospace')
            ax.set_ylabel('x2', fontsize=12, fontname='monospace')
            ax.set_zlabel('x3', fontsize=12, fontname='monospace')

        P.grid(color='DarkGray', linestyle='--', linewidth=0.1, axis='both')

        for c in range(len(classNames)):
            X,Y,Z = [], [], []
            for labelIndex in range(len(dataLabels)):
                if c == dataLabels[labelIndex]:
                    X.append(dataSamples[labelIndex,:].tolist()[0])
                    Y.append(dataSamples[labelIndex,:].tolist()[1])
                    if dimension == 3:
                        Z.append(dataSamples[labelIndex,:].tolist()[2])

            # Plot points of that class
            #P.plot(Y, X, color='#%02X%02X%02X' % (randomColor(), randomColor(), randomColor()), marker=markers[c], markeredgecolor='None', markersize=4.0, linestyle='None', label=classNames[c])
            if dimension == 2:
                P.plot(Y, X, color=colors[c % len(colors)], marker=markers[c % len(markers)], markersize=5.0, linestyle='None', label=classNames[c])
            else:
                ax.scatter(X,Y,Z,c=colors[c % len(colors)], marker=markers[c % len(markers)])

        if dimension == 2:
            #P.legend([x.split(",")[-1] for x in classNames], fontsize='xx-small', numpoints=1, fancybox=True)
            P.legend([x for x in classNames], fontsize='xx-small', numpoints=1, fancybox=True)
        else:
            ax.legend([x for x in classNames], fontsize='xx-small', numpoints=1, fancybox=True)

        prettyPrint("Saving results to ./%s" % filename)#(graphTitle, timestamp))
        P.tight_layout()
        fig.savefig("./%s" % filename)#(graphTitle, timestamp))

    except Exception as e:
        prettyPrint("Error encountered in \"plotReductionGraph\": %s" % e, "error")
        return False

    return True


问题


面经


文章

微信
公众号

扫码关注公众号