title: How can I retain desired order in R Plotly bar chart with color variable
body: <p>Pretty self-evident. Values on x-axis are not ordered correctly if color parameter is invoked</p>
  
  <pre><code>df &lt;- structure(list(count = c(8, 3, 5, 9), names = c("I", "want", 
  "this", "order"), type = c("H", "A", "H", "A")), .Names = c("count", 
  "names", "type"), row.names = c(NA, -4L), class = "data.frame")
  
  plot_ly(data=df,x=names,y=count,type="bar",
     color = type)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jxu1C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jxu1C.png" alt="enter image description here"></a> 
  This is somewhat similar to <a href="https://stackoverflow.com/questions/34643272/color-in-plotly-bar-chart">a previous question</a> but that seemed a bit of a hack that may be difficult to apply here anyways</p>
  
  <p>TIA</p>