Without a fully reproducible example, it is hard to know if this will solve your problem or not, but in general if you are converting a ggplot2 plot, you should use ggplotly instead of plot_ly. plot_ly is designed for directly building a Plotly htmlwidget without help from ggplot2. So, code something like the following should work.
p=ggplot(data,aes(x,fill=(y)))
p=p+geom_bar()
p
ggplotly(p)