title: Create a stacked ggplot2 bar chart with numbers in x-axis
body: <p>I have a data frame from which I want to create a stacked bar chart with 1 and 2 in x-axis and while their values will be stacked and colored according to their values.</p>
  
  <pre><code>one=c(0.4,0.3)
  two=c(0.4,0.5)
  df=data.frame(one,two)
  colnames(df) &lt;- c("1", "2")
  
  ggplot(df,aes(df[,1:2]))+
    geom_bar(position = "stack")
  })
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/DhagI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DhagI.png" alt="enter image description here"></a></p>
  
  <p>Also when Im trying to convert it to plotly I get ggplot2 doesn't know how to deal with data of class uneval</p>
  
  <pre><code>library(tidyverse)
  gather(df)  %&gt;% 
     p1&lt;-ggplot(aes(x = key, y = value, 
           fill = factor(value, levels = sort(unique(value))))) + 
            geom_bar(stat = "identity")
  ggplotly(p1)
  </code></pre>