plfit/plfit.py
def plotcdf(self, x=None, xmin=None, alpha=None, pointcolor='k',
                dolog=True, zoom=True, pointmarker='+', **kwargs):
        """
        Plots CDF and powerlaw
        """
        if x is None: x=self.data
        if xmin is None: xmin=self._xmin
        if alpha is None: alpha=self._alpha

        x=np.sort(x)
        n=len(x)
        xcdf = np.arange(n,0,-1,dtype='float')/float(n)

        q = x[x>=xmin]
        fcdf = (q/xmin)**(1-alpha)
        nc = xcdf[argmax(x>=xmin)]
        fcdf_norm = nc*fcdf

        D_location = argmax(xcdf[x>=xmin]-fcdf_norm)
        pylab.vlines(q[D_location], xcdf[x>=xmin][D_location],
                     fcdf_norm[D_location], color='m', linewidth=2, zorder=2)
        pylab.plot([q[D_location]]*2,
                   [xcdf[x>=xmin][D_location], fcdf_norm[D_location]],
                   color='m',
                   marker='s', zorder=3)

        #plotx = pylab.linspace(q.min(),q.max(),1000)
        #ploty = (plotx/xmin)**(1-alpha) * nc

        if dolog:
            pylab.loglog(x,xcdf,marker=pointmarker,color=pointcolor,**kwargs)
            pylab.loglog(q,fcdf_norm,'r',**kwargs)
        else:
            pylab.semilogx(x,xcdf,marker=pointmarker,color=pointcolor,**kwargs)
            pylab.semilogx(q,fcdf_norm,'r',**kwargs)

        if zoom:
            pylab.axis([xmin, x.max(), xcdf.min(), nc])
def plotcdf(self, x=None, xmin=None, alpha=None, pointcolor='k',
                dolog=True, zoom=True, pointmarker='+', **kwargs):
        """
        Plots CDF and powerlaw
        """
        if x is None: x=self.data
        if xmin is None: xmin=self._xmin
        if alpha is None: alpha=self._alpha

        x=np.sort(x)
        n=len(x)
        xcdf = np.arange(n,0,-1,dtype='float')/float(n)

        q = x[x>=xmin]
        fcdf = (q/xmin)**(1-alpha)
        nc = xcdf[argmax(x>=xmin)]
        fcdf_norm = nc*fcdf

        D_location = argmax(xcdf[x>=xmin]-fcdf_norm)
        pylab.vlines(q[D_location], xcdf[x>=xmin][D_location],
                     fcdf_norm[D_location], color='m', linewidth=2, zorder=2)
        pylab.plot([q[D_location]]*2,
                   [xcdf[x>=xmin][D_location], fcdf_norm[D_location]],
                   color='m',
                   marker='s', zorder=3)

        #plotx = pylab.linspace(q.min(),q.max(),1000)
        #ploty = (plotx/xmin)**(1-alpha) * nc

        if dolog:
            pylab.loglog(x,xcdf,marker=pointmarker,color=pointcolor,**kwargs)
            pylab.loglog(q,fcdf_norm,'r',**kwargs)
        else:
            pylab.semilogx(x,xcdf,marker=pointmarker,color=pointcolor,**kwargs)
            pylab.semilogx(q,fcdf_norm,'r',**kwargs)

        if zoom:
            pylab.axis([xmin, x.max(), xcdf.min(), nc])
def plotcdf ( self , x = None , xmin = None , alpha = None , pointcolor = 'k' , dolog = True , zoom = True , pointmarker = '+' , * * kwargs ) : if x is None : x = self . data if xmin is None : xmin = self . _xmin if alpha is None : alpha = self . _alpha x = np . sort ( x ) n = len ( x ) xcdf = np . arange ( n , 0 , - 1 , dtype = 'float' ) / float ( n ) q = x [ x >= xmin ] fcdf = ( q / xmin ) ** ( 1 - alpha ) nc = xcdf [ argmax ( x >= xmin ) ] fcdf_norm = nc * fcdf D_location = argmax ( xcdf [ x >= xmin ] - fcdf_norm ) pylab . vlines ( q [ D_location ] , xcdf [ x >= xmin ] [ D_location ] , fcdf_norm [ D_location ] , color = 'm' , linewidth = 2 , zorder = 2 ) pylab . plot ( [ q [ D_location ] ] * 2 , [ xcdf [ x >= xmin ] [ D_location ] , fcdf_norm [ D_location ] ] , color = 'm' , marker = 's' , zorder = 3 ) #plotx = pylab.linspace(q.min(),q.max(),1000) #ploty = (plotx/xmin)**(1-alpha) * nc if dolog : pylab . loglog ( x , xcdf , marker = pointmarker , color = pointcolor , * * kwargs ) pylab . loglog ( q , fcdf_norm , 'r' , * * kwargs ) else : pylab . semilogx ( x , xcdf , marker = pointmarker , color = pointcolor , * * kwargs ) pylab . semilogx ( q , fcdf_norm , 'r' , * * kwargs ) if zoom : pylab . axis ( [ xmin , x . max ( ) , xcdf . min ( ) , nc ] )
Plots CDF and powerlaw
Plots CDF and powerlaw