I am trying to get the percentage labels on top of the stacked bars, but I can't figure it out.
 fig, ax = plt.subplots(figsize=(24, 8))
    minor_treatment_choice.plot( 
      x = 'surgeon_id',  
      kind = 'bar',  
      stacked = True, ax=ax) 
      
    df_total = (minor_treatment_choice['X'] + minor_treatment_choice['Y'])
    df_rel = minor_treatment_choice[minor_treatment_choice.columns[2:]].div(df_total, 0.)*100.
    
    for n in df_rel: 
        for i, (cs, ab, pc) in enumerate(zip(minor_treatment_choice.iloc[:, 2:].cumsum(1)[n], minor_treatment_choice[n], df_rel[n])): 
            plt.text(cs - ab / 2, i, str(np.round(pc, 1)) + '%',  va = 'center', ha = 'center', fontsize = 10)
    
    plt.xticks(fontsize=15,rotation=30)
    plt.yticks(fontsize=15)
    ax.set_xlabel ('Surgeon IDs',fontsize=15)
    ax.set_ylabel ('Minor Severity Cases',fontsize=15)
    fig.suptitle('Treatments X & Y for Minor Cases',fontsize=20)
    ax.legend(title='Treatments')
    plt.show()
Can anyone help?

