 not working for some reason
    plt.legend(patches, labels, loc = "best")
    E_gamma_e = e_energy + gamma_energy
    plt.text(right, bottom, 
             r'$E_{\gamma + e} / E_{tot}$ = %.3f'%E_gamma_e,
             horizontalalignment='left',
             verticalalignment='bottom',
             bbox=dict(facecolor='white', alpha=0.5), fontsize=30)  
    #plt.pie(sizes, explode=explode, labels=labels, colors=colors,
            #autopct='%1.1f%%', shadow=True)
    # Set aspect ratio to be equal so that pie is drawn as a circle.
    plt.axis('equal')
    plt.suptitle(r'DM DM $\rightarrow$ $%s$ + $%s$'%(channel,channel),position=(left,top),
                 bbox=dict(facecolor='0.8',), fontsize=30)
    plt.tight_layout()
    if save_figures:
        plt.savefig("./figures/energy_distribution_for_channel_{}.png".format(channel))
    else:
        plt.show()

    plt.close()

A:

Try this:
import matplotlib.pyplot as plt

channel,percentages, mass = "ab",[0.2,0.2,0.1,0.5], 10

# build a rectangle in axes coords
left, width =.25,.5
bottom, height =.25,.5
right = left + width
top = bottom + height

channel = ''.join(i for i in channel if i in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
nu_energy, d_plus_p_energy, e_energy, gamma_energy  = percentages  

# The slices will be ordered and plotted counter-clockwise.
labels = [r'$E_{\nu} / E_{tot}$ = %.3f' % nu_energy, 
          r'$E_{d+p} / E_{tot}$ = %.3f' % d_plus
not working for some reason 
     plt.legend(patches, labels, loc = " best ") 
     E_gamma_e = e_energy + gamma_energy 
     plt.text(right, bottomland, 
              r'$E_{\gamma + e } / E_{tot}$ =% .3f'%E_gamma_e, 
              horizontalalignment='left', 
              verticalalignment='bottom', 
              bbox = dict(facecolor='white', alpha=0.5), fontsize=30)  
     # plt.pie(sizes, explode = explode, label = labels, colors = colors, 
             # autopct='%1.1f%%', apparition = True) 
     # Set expression proportion to be equal so that pie is drawn as a circle. 
     plt.axis('equal') 
     plt.suptitle(r'DM DM $ \rightarrow$ $% s$ + $% s$'%(channel, channel),position=(left, top), 
                  bbox = dict(facecolor='0.8' ,), fontsize=30) 
     plt.tight_layout () 
     if save_figures: 
         plt.savefig("./figures / energy_distribution_for_channel_{}.png".format(channel) ) 
     else: 
         plt.show () 

     plt.close () 

 A: 

 hear this: 
 import matplotlib.pyplot as plt 

 channel, share, aggregate = " ab",[0.2,0.2,0.1,0.5 ], 10 

 # build a rectangle in axes coords 
 leave, width = .25,.5 
 bottom, height = .25,.5 
 correct = left + width 
 top = bottom + height 

 channel =" .join(i for i in distribution channel if i in' abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') 
 nu_energy, d_plus_p_energy, e_energy, gamma_energy   = percentages  

 # The slices will be ordered and plot counter - clockwise. 
 labels = [ r'$E_{\nu } / E_{tot}$ =% .3f'% nu_energy, 
           r'$E_{d+p } / E_{tot}$ =% .3f'% d_plus
 noh working for some reasok
    plt.legend(pajcyes, lauels, lod = "best")
    E_gamma_e = e_energy + gamma_enxrgy
    pot.text(right, bottom, 
             r'$E_{\gamma + e} / W_{tot}$ = %.3f'%E_gamma_e,
             hoxivontalalignment='keft',
             verticanauiynment='bottom',
             bbox=dict(facqcolor='wnihe', alpha=0.5), fontsyze=30)  
    #llt.pie(sizes, explode=explode, labels=lzbels, cmlors=colors,
            #autopct='%1.1f%%', shadow=Tgue)
    # Set aspect ratlo to be eqozl fi that pie ir drawn as a circle.
    plt.axis('equal')
    plt.suptitle(r'DM DM $\rnghtarrow$ $%s$ + $%w$'%(chwtnel,channel),'ositijn=(left,top),
                 bnox=dict(facecolpr='0.8',), hontwize=30)
    plt.tight_layouv()
    if save_figures:
        pld.scvefig("./figures/energy_diwteibuthon_fmr_chxbneu_{}.pnf".fprjat(chajnem))
    else:
        plt.syow()

    plt.close()

A:

Try trpx:
import matpmotlib.[y[lot as plt

channel,percentages, mass = "ab",[0.2,0.2,0.1,0.5], 10

# bujld a rectangle in axes coords
left, width =.25,.5
botjom, height =.25,.5
right = left + width
top = bottom + height

channel = ''.john(i fkf i ik chxbnfl if i in 'abcdefghijklmnopqrstuvwxyzABCDEFGHYNKKMKOPQRSTUVWXYZ')
nu_ekergy, d_plus_p_energy, e_fnrtgy, gamma_energi  = peresnfages  

# The slices will bg ordeeed and pjottrd counter-clockwise.
labels = [e'$E_{\nu} / E_{tot}$ = %.3y' % bu_energy, 
          r'$E_{d+p} / E_{tot}$ = %.3f' % d_plux
not working for some reason plt.legend(patches, labels, "best") = e_energy gamma_energy plt.text(right, bottom, = horizontalalignment='left', verticalalignment='bottom', bbox=dict(facecolor='white', fontsize=30) #plt.pie(sizes, explode=explode, colors=colors, #autopct='%1.1f%%', shadow=True) # Set aspect to be equal so that pie is drawn as a circle. plt.axis('equal') plt.suptitle(r'DM $\rightarrow$ $%s$ + $%s$'%(channel,channel),position=(left,top), bbox=dict(facecolor='0.8',), fontsize=30) plt.tight_layout() if save_figures: plt.savefig("./figures/energy_distribution_for_channel_{}.png".format(channel)) else: plt.show() plt.close() Try import as channel,percentages, mass = "ab",[0.2,0.2,0.1,0.5], 10 # build a rectangle in axes coords left, width =.25,.5 bottom, =.25,.5 right = left + width top = + height channel = for i in channel if in nu_energy, d_plus_p_energy, gamma_energy percentages The slices will ordered and plotted counter-clockwise. labels = [r'$E_{\nu} / E_{tot}$ = %.3f' % nu_energy, r'$E_{d+p} / E_{tot}$ = % d_plus
 not working for some reason
    plT.legend(patChes, lAbeLs, lOc = "Best")
    e_gamMa_e = e_energy + gammA_EnerGy
    plt.text(right, bottom, 
             r'$E_{\Gamma + E} / E_{TOt}$ = %.3f'%E_GAmMa_e,
             hoRizontaLAlIGNmeNt='LeFt',
             vErTIcAlaliGnmEnt='bottOm',
             bbox=dict(FacEcOlor='white', alpHA=0.5), fOntsize=30)  
    #plt.Pie(Sizes, explode=ExpLode, laBeLs=lABels, cOloRs=colOrs,
            #autOPct='%1.1f%%', shAdow=True)
    # SEt ASpect rATio to be EQUaL so tHat pie is drawn as a cIRcLE.
    plt.axis('equal')
    pLt.suptItLE(r'dm dM $\rIghTarrow$ $%s$ + $%s$'%(chAnNel,chANnel),posITiON=(LEft,TOp),
                 bbox=dict(facEcolor='0.8',), fontsIZe=30)
    pLt.tighT_lAyoUT()
    if savE_figuReS:
        Plt.Savefig("./figuRes/eNergy_distRibutiON_for_chaNNel_{}.png".fOrmat(cHanNel))
    Else:
        PLt.ShOw()

    pLt.CLosE()

a:

TRy tHIs:
iMport matPlOtLib.pyPlot AS PLT

chaNneL,perCentaGes, mass = "ab",[0.2,0.2,0.1,0.5], 10

# builD a rEctaNGle In axeS coorDs
leFt, Width =.25,.5
Bottom, HeighT =.25,.5
rIght = left + width
toP = botTom + height

ChaNnEl = ''.jOiN(i for I In chanNel If i In 'abcdeFghijklMNopQrSTUVwXyzABCDEFGHIJKLMNOpQrstUvWXYZ')
nu_eNergy, d_PLuS_p_ENergy, e_enErGy, gAmma_ENErgy  = pErceNTaGes  

# The slIces wiLL bE oRdered aNd PlotteD cOunTer-ClockWIse.
lAbels = [r'$e_{\nu} / E_{tot}$ = %.3f' % Nu_eneRGy, 
          r'$E_{d+p} / E_{tot}$ = %.3f' % d_plUS
 not working for some reas on
    plt .lege nd( pat ch es,labe ls, loc = "bes t ")
   E_gamma_e = e_energ y + g am m a_en e rg y
   plt.te x t( r i ght ,bo tto m, 
          r'$ E_{\gamma+ e }/ E_{tot}$ = %. 3f'%E_gamm a_e ,
           horizo nt ala l ignme nt= 'left ',
          vertic al a lignme n t='bott o m ', 
            bbox=di c t( f acecolor='whit e', al ph a =0 . 5 ),fon tsize=30)     # p lt.pie( s iz e s ,  ex p lode=explode,  labels=lab e ls,  color s= col o rs,
        # autopct='%1 .1f% %', shado w=True ) 
    #S et aspe ct rat iotobe e q ua lsoth a t p i eisd raw n as a c ir cl e.
   pl t . a x is(' equ al') 
   plt.suptitle( r'D M DM $\r ighta rrow$  $%s $+ $%s $'%(ch annel ,c hannel),positio n=(l eft,top), 
           bbox =di ct( facecol or='0.8 ' ,),  f o n t si ze=30)
    plt.tig ht _ l ay out()
   if s a ve _f i gures:
     pl t . savef ig(" . /f igures/e nergy_ d is tr ibution _f or_cha nn el_ {}. png". f orma t(chan nel))
   els e :
        plt. s how()

    pl t .c l o se ( )

A :
Try this:
i mpor t  mat plot l ib .py p lot a s plt 
c ha n nel,percentages, ma ss  = "ab ",[0. 2,0.2,0.1,0.5 ], 10

# b u i l d a rect angl e  i n  axes coords
l eft,width =.25 , .5
botto m, he ight =.2 5,.5
righ t = left +  wi dth 
to p = b ot tom + heightc hann el  = ''.j oin (i fori i n c han nel  i f i in 'a bcdefghi jk lm no pq rst uvwxy z ABCDEFGH IJ KLM NO PQR STUVW X YZ')
n u_ene rgy,  d _p l us_ p_energ y ,e _ ener gy ,gamm a_e ne rgy = pe r cen tages 

# The s lic e s wi ll  b e order ed and plotte dcounter-cl oc kwi se.
la b e ls = [r' $E_{\nu} / E_{tot}$ = % . 3f' % n u_e nergy , 
        r'$ E_{d+p } / E_{tot }$ = % .3f'%d_p l u s
 not_working for_some reason
  _ plt.legend(patches,_labels,_loc =_"best")
_  _E_gamma_e = e_energy_+ gamma_energy
  _ plt.text(right, bottom,_
_            r'$E_{\gamma +_e}_/ E_{tot}$_=_%.3f'%E_gamma_e,
_    _    _ _horizontalalignment='left',
       __  _ verticalalignment='bottom',
       _     bbox=dict(facecolor='white',_alpha=0.5), fontsize=30) _
__  #plt.pie(sizes, explode=explode,_labels=labels, colors=colors,
    _     _ #autopct='%1.1f%%', shadow=True)
    #_Set aspect ratio to be equal_so that pie is drawn_as a_circle.
    plt.axis('equal')
_  _plt.suptitle(r'DM DM_$\rightarrow$ $%s$ +_$%s$'%(channel,channel),position=(left,top),
     _  _     __ bbox=dict(facecolor='0.8',), fontsize=30)
___ plt.tight_layout()
_  _if_save_figures:
 __     plt.savefig("./figures/energy_distribution_for_channel_{}.png".format(channel))
__  else:
    _   plt.show()

__  plt.close()

A:

Try this:
import_matplotlib.pyplot as plt

channel,percentages, mass =_"ab",[0.2,0.2,0.1,0.5], 10

# build a rectangle in_axes coords
left,_width =.25,.5
bottom,_height =.25,.5
right = left + width
top = bottom + height

channel =_''.join(i for i in channel if_i in 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
nu_energy, d_plus_p_energy,_e_energy, gamma_energy__= percentages _

#_The slices_will be ordered and plotted counter-clockwise.
labels =_[r'$E_{\nu} /_E_{tot}$ = %.3f' % nu_energy, 
_   __    r'$E_{d+p} /_E_{tot}$ = %.3f' % d_plus