title: Adding percentage of count to a stacked bar chart in plotly
body: <p>Given the following chart created in plotly.
  <a href="https://i.stack.imgur.com/yCNPd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yCNPd.png" alt="enter image description here" /></a></p>
  <p>I want to add the percentage values of each count for M and F categories inside each block.</p>
  <p>The code used to generate this plot.</p>
  <pre class="lang-py prettyprint-override"><code>arr = np.array([
          ['Dog', 'M'], ['Dog', 'M'], ['Dog', 'F'], ['Dog', 'F'],
          ['Cat', 'F'], ['Cat', 'F'], ['Cat', 'F'], ['Cat', 'M'],
          ['Fox', 'M'], ['Fox', 'M'], ['Fox', 'M'], ['Fox', 'F'],
          ['Dog', 'F'], ['Dog', 'F'], ['Cat', 'F'], ['Dog', 'M']
      ])
  
  df = pd.DataFrame(arr, columns=['A', 'G'])
  
  fig = px.histogram(df, x=&quot;A&quot;, color='G', barmode=&quot;stack&quot;)
  fig.update_layout(height=400, width=800)
  
  fig.show()
  </code></pre>