title: Stacked barplot using R base: how to add values inside each stacked bar
body: <p>I found a plot in a stats book, which I want to reproduce with the base package. </p>
  
  <p>The plot looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/etIoq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/etIoq.png" alt="enter image description here"></a></p>
  
  <p>So far I have the plot, but I have problems to add a centred labels to each part of the bar. </p>
  
  <p>My code looks like this:</p>
  
  <pre><code>data   &lt;- sample( 5, 10 , replace = TRUE )
  
  colors &lt;- c('yellow','violet','green','pink','red')
  
  relative.frequencies &lt;- as.matrix( prop.table( table( data ) ) )
  
  bc &lt;- barplot( relative.frequencies, horiz = TRUE, axes = FALSE, col = colors )
  </code></pre>