def constraint_piechart(self,primarylist=None,
                            fig=None,title='',colordict=None,
                            legend=True,nolabels=False):
        """Makes piechart illustrating constraints on population

        :param primarylist: (optional)
            List of most import constraints to show (see
            :func:`StarPopulation.constraint_stats`)

        :param fig: (optional)
            Passed to :func:`plotutils.setfig`.

        :param title: (optional)
            Title for pie chart

        :param colordict: (optional)
            Dictionary describing colors (keys are constraint names).

        :param legend: (optional)
            ``bool`` indicating whether to display a legend.

        :param nolabels: (optional)
            If ``True``, then leave out legend labels.

        """

        setfig(fig,figsize=(6,6))
        stats = self.constraint_stats(primarylist=primarylist)
        if primarylist is None:
            primarylist = []
        if len(primarylist)==1:
            primaryname = primarylist[0]
        else:
            primaryname = ''
            for name in primarylist:
                primaryname += '%s,' % name
            primaryname = primaryname[:-1]
        fracs = []
        labels = []
        explode = []
        colors = []
        fracs.append(stats['remaining']*100)
        labels.append('remaining')
        explode.append(0.05)
        colors.append('b')
        if 'pri' in stats and stats['pri']>=0.005:
            fracs.append(stats['pri']*100)
            labels.append(primaryname)
            explode.append(0)
            if colordict is not None:
                colors.append(colordict[primaryname])
        for name in stats:
            if name == 'pri' or \
                    name == 'multiple constraints' or \
                    name == 'remaining':
                continue

            fracs.append(stats[name]*100)
            labels.append(name)
            explode.append(0)
            if colordict is not None:
                colors.append(colordict[name])

        if stats['multiple constraints'] >= 0.005:
            fracs.append(stats['multiple constraints']*100)
            labels.append('multiple constraints')
            explode.append(0)
            colors.append('w')

        autopct = '%1.1f%%'

        if nolabels:
            labels = None
        if legend:
            legendlabels = []
            for i,l in enumerate(labels):
                legendlabels.append('%s (%.1f%%)' % (l,fracs[i]))
            labels = None
            autopct = ''
        if colordict is None:
            plt.pie(fracs,labels=labels,autopct=autopct,explode=explode)
        else:
            plt.pie(fracs,labels=labels,autopct=autopct,explode=explode,
                    colors=colors)
        if legend:
            plt.legend(legendlabels,bbox_to_anchor=(-0.05,0),
                       loc='lower left',prop={'size':10})
        plt.title(title)
def constraint_piechart ( self , primarylist = None , fig = None , title = '' , colordict = None , legend = True , nolabels = False ) : setfig ( fig , figsize = ( 6 , 6 ) ) stats = self . constraint_stats ( primarylist = primarylist ) if primarylist is None : primarylist = [ ] if len ( primarylist ) == 1 : primaryname = primarylist [ 0 ] else : primaryname = '' for name in primarylist : primaryname += '%s,' % name primaryname = primaryname [ : - 1 ] fracs = [ ] labels = [ ] explode = [ ] colors = [ ] fracs . append ( stats [ 'remaining' ] * 100 ) labels . append ( 'remaining' ) explode . append ( 0.05 ) colors . append ( 'b' ) if 'pri' in stats and stats [ 'pri' ] >= 0.005 : fracs . append ( stats [ 'pri' ] * 100 ) labels . append ( primaryname ) explode . append ( 0 ) if colordict is not None : colors . append ( colordict [ primaryname ] ) for name in stats : if name == 'pri' or name == 'multiple constraints' or name == 'remaining' : continue fracs . append ( stats [ name ] * 100 ) labels . append ( name ) explode . append ( 0 ) if colordict is not None : colors . append ( colordict [ name ] ) if stats [ 'multiple constraints' ] >= 0.005 : fracs . append ( stats [ 'multiple constraints' ] * 100 ) labels . append ( 'multiple constraints' ) explode . append ( 0 ) colors . append ( 'w' ) autopct = '%1.1f%%' if nolabels : labels = None if legend : legendlabels = [ ] for i , l in enumerate ( labels ) : legendlabels . append ( '%s (%.1f%%)' % ( l , fracs [ i ] ) ) labels = None autopct = '' if colordict is None : plt . pie ( fracs , labels = labels , autopct = autopct , explode = explode ) else : plt . pie ( fracs , labels = labels , autopct = autopct , explode = explode , colors = colors ) if legend : plt . legend ( legendlabels , bbox_to_anchor = ( - 0.05 , 0 ) , loc = 'lower left' , prop = { 'size' : 10 } ) plt . title ( title )
Makes piechart illustrating constraints on population

        :param primarylist: (optional)
            List of most import constraints to show (see
            :func:`StarPopulation.constraint_stats`)

        :param fig: (optional)
            Passed to :func:`plotutils.setfig`.

        :param title: (optional)
            Title for pie chart

        :param colordict: (optional)
            Dictionary describing colors (keys are constraint names).

        :param legend: (optional)
            ``bool`` indicating whether to display a legend.

        :param nolabels: (optional)
            If ``True``, then leave out legend labels.