title: How can I have different color for each bar of stack barplots? in R
body: <p>My question maybe very simple but I couldn't find the answer! 
  I have a matrix with 12 entries and I made a stack barplot with barplot function in R. 
  With this code:</p>
  
  <pre><code>    mydata &lt;- matrix(nrow=2,ncol=6, rbind(sample(1:12, replace=T)))
  
      barplot(mydata, xlim=c(0,25),horiz=T, 
      legend.text = c("A","B","C","D","E","F"),
  col=c("blue","green"),axisnames = T, main="Stack barplot")
  </code></pre>
  
  <p>Here is the image from the code:</p>
  
  <p><img src="https://i.stack.imgur.com/vCEf9.jpg" alt="enter image description here"></p>
  
  <p>What I want to do is to give each of the group (A:F , only the blue part) a different color but I couldn't add more than two color.</p>
  
  <p>and I also would like to know how can I start the plot from x=2 instead of 0. 
  I know it's possible to choose the range of x by using xlim=c(2,25) but when I choose that part of my bars are out of range and I get picture like this:</p>
  
  <p><img src="https://i.stack.imgur.com/j1QOd.jpg" alt="enter image description here"></p>
  
  <p>What I want is to ignore the part of bars that are smaller than 2 and start the x-axis from two and show the rest of bars instead of put them out of range.</p>
  
  <p>Thank you in advance,</p>