PEATDB/Ekin/Titration.py
def plotHistograms(cls, ax, data, bins=25, title='', xlabel=None, ylabel=None, color=None,
                          colors=False, xticks=True, yticks=True, xlim=None):
        """Do a pylab histogram overlaying 1 or more dicts on the same axis
            and using the same bins, so that they are clearly visible"""
        import Utils
        pyclrs = cls.pylabcolors
        if color == None:
            clr = 'blue'
        else:
            clr = color

        patches={}
        for h in data.keys():
            if len(data[h])==0:
                del data[h]
                continue
        if len(data)==0:
            return

        handles=[]
        if None in data.keys():
            del data[None]
        names = data.keys()

        legnames=[]
        for key in names:
            if key in cls.atom_greek:
                legnames.append(cls.atom_greek[key])
            else:
                legnames.append(key)


        #if len(data) > 1:
        mybins = Utils.get_bins(data, bins)
        w= max(mybins)/len(mybins)
        if mybins == None:
            return
        #else:
        #    mybins = bins
        #    w=1.0/bins

        h=0
        if len(data) > 0:
            for key in names:
                if len(data[key]) == 0:
                    h+=1
                    continue
                n, b, patches[h] = pylab.hist(data[key], bins=mybins, facecolor=pyclrs[h])#, alpha=0.9)
                hd, x = numpy.histogram(data[key], bins=mybins)
                #patches[h] = ax.bar(mybins[:len(mybins)-1], hd, width=w, color=pyclrs[h],
                #                    alpha=0.8)
                handles.append(patches[h][0])
                h+=1

            leg = ax.legend(handles, legnames, shadow=True, numpoints=1, loc='best',
                            markerscale = 0.8, prop = FontProperties(size='smaller'),
                            handletextsep = 0.04)

            leg.draw_frame(False)
        i=0
        '''for pa in patches:
            for rect in patches[pa]:
                #print patches[pa]
                #rect.set_x(rect.get_x() + i)
                #print p.get_zorder()
                #p.set_linewidth(1.1)
                rect.set_edgecolor('#737CA1')
                rect.set_zorder(0)
                #p.set_antialiased(False)
            i+=w'''
        #reorder bars, so that smallest are at front
        Utils.adjust_bars(patches)

        ax.set_title(title)

        if xlabel != None:
            ax.set_xlabel(xlabel)
        if ylabel != None:
            ax.set_ylabel(ylabel)
        if xlim != None:
            ax.set_xlim(xlim)
        if xticks != True:
            ax.set_xticks(pylab.xlim())
        if yticks != True:
            ax.set_yticks(pylab.ylim())

        return
Do a pylab histogram overlaying 1 or more dicts on the same axis
            and using the same bins, so that they are clearly visible
Do a pylab histogram overlaying 1 or more dicts on the same axis
and using the same bins, so that they are clearly visible
Do a pylab histogram overlaying 1 or more dicts on the same axis and using the same bins so that they are clearly visible
def plotHistograms(cls, ax, data, bins=25, title='', xlabel=None, ylabel=None, color=None,
                          colors=False, xticks=True, yticks=True, xlim=None):
        import Utils
        pyclrs = cls.pylabcolors
        if color == None:
            clr = 'blue'
        else:
            clr = color
        patches={}
        for h in data.keys():
            if len(data[h])==0:
                del data[h]
                continue
        if len(data)==0:
            return
        handles=[]
        if None in data.keys():
            del data[None]
        names = data.keys()
        legnames=[]
        for key in names:
            if key in cls.atom_greek:
                legnames.append(cls.atom_greek[key])
            else:
                legnames.append(key)
        mybins = Utils.get_bins(data, bins)
        w= max(mybins)/len(mybins)
        if mybins == None:
            return
        h=0
        if len(data) > 0:
            for key in names:
                if len(data[key]) == 0:
                    h+=1
                    continue
                n, b, patches[h] = pylab.hist(data[key], bins=mybins, facecolor=pyclrs[h])
                hd, x = numpy.histogram(data[key], bins=mybins)
                handles.append(patches[h][0])
                h+=1
            leg = ax.legend(handles, legnames, shadow=True, numpoints=1, loc='best',
                            markerscale = 0.8, prop = FontProperties(size='smaller'),
                            handletextsep = 0.04)
            leg.draw_frame(False)
        i=0
        Utils.adjust_bars(patches)
        ax.set_title(title)
        if xlabel != None:
            ax.set_xlabel(xlabel)
        if ylabel != None:
            ax.set_ylabel(ylabel)
        if xlim != None:
            ax.set_xlim(xlim)
        if xticks != True:
            ax.set_xticks(pylab.xlim())
        if yticks != True:
            ax.set_yticks(pylab.ylim())
        return
def plotHistograms ( cls , ax , data , bins = 25 , title = '' , xlabel = None , ylabel = None , color = None , colors = False , xticks = True , yticks = True , xlim = None ) : import Utils pyclrs = cls . pylabcolors if color == None : clr = 'blue' else : clr = color patches = { } for h in data . keys ( ) : if len ( data [ h ] ) == 0 : del data [ h ] continue if len ( data ) == 0 : return handles = [ ] if None in data . keys ( ) : del data [ None ] names = data . keys ( ) legnames = [ ] for key in names : if key in cls . atom_greek : legnames . append ( cls . atom_greek [ key ] ) else : legnames . append ( key ) mybins = Utils . get_bins ( data , bins ) w = max ( mybins ) / len ( mybins ) if mybins == None : return h = 0 if len ( data ) > 0 : for key in names : if len ( data [ key ] ) == 0 : h += 1 continue n , b , patches [ h ] = pylab . hist ( data [ key ] , bins = mybins , facecolor = pyclrs [ h ] ) hd , x = numpy . histogram ( data [ key ] , bins = mybins ) handles . append ( patches [ h ] [ 0 ] ) h += 1 leg = ax . legend ( handles , legnames , shadow = True , numpoints = 1 , loc = 'best' , markerscale = 0.8 , prop = FontProperties ( size = 'smaller' ) , handletextsep = 0.04 ) leg . draw_frame ( False ) i = 0 '''for pa in patches:
            for rect in patches[pa]:
                #print patches[pa]
                #rect.set_x(rect.get_x() + i)
                #print p.get_zorder()
                #p.set_linewidth(1.1)
                rect.set_edgecolor('#737CA1')
                rect.set_zorder(0)
                #p.set_antialiased(False)
            i+=w''' Utils . adjust_bars ( patches ) ax . set_title ( title ) if xlabel != None : ax . set_xlabel ( xlabel ) if ylabel != None : ax . set_ylabel ( ylabel ) if xlim != None : ax . set_xlim ( xlim ) if xticks != True : ax . set_xticks ( pylab . xlim ( ) ) if yticks != True : ax . set_yticks ( pylab . ylim ( ) ) return
Do a pylab histogram overlaying 1 or more dicts on the same axis
and using the same bins, so that they are clearly visible
Do a pylab histogram overlaying 1 or more dicts on the same axis and using the same bins so that they are clearly visible
"""Do a pylab histogram overlaying 1 or more dicts on the same axis
            and using the same bins, so that they are clearly visible""" #if len(data) > 1: #else: #    mybins = bins #    w=1.0/bins #, alpha=0.9) #patches[h] = ax.bar(mybins[:len(mybins)-1], hd, width=w, color=pyclrs[h], #                    alpha=0.8) '''for pa in patches:
            for rect in patches[pa]:
                #print patches[pa]
                #rect.set_x(rect.get_x() + i)
                #print p.get_zorder()
                #p.set_linewidth(1.1)
                rect.set_edgecolor('#737CA1')
                rect.set_zorder(0)
                #p.set_antialiased(False)
            i+=w''' #reorder bars, so that smallest are at front
cls
ax
data
bins
title
xlabel
ylabel
color
colors
xticks
yticks
xlim