title: How to turn the color scale in Plotly r to log scale
body: <p>I am trying to have a logarithmic scale for the color bar in R, any ideas on how I can do it?</p>
  
  <p>My code: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>TEST_DATAFRAME = read.table(TEST_FILE, sep="\t",skip=2, header=T)
  PROD_DATAFRAME = read.table(PROD_FILE, sep="\t",skip=2, header=T)
  
  PARAMETER = "Vf_High"
  LST_RESIDUAL &lt;- PROD_DATAFRAME[PARAMETER] - TEST_DATAFRAME[PARAMETER]
  PARAM_DATAFRAME &lt;- data.frame("NEW_MEASUREMENT" = TEST_DATAFRAME[PARAMETER], 
                                "OLD_MEASUREMENT" = PROD_DATAFRAME[PARAMETER], 
                                "RESIDUAL" = LST_RESIDUAL)
  
  colnames(PARAM_DATAFRAME) &lt;- c("NEW_MEASUREMENT","OLD_MEASUREMENT","RESIDUAL")
  
  p &lt;- plot_ly(PARAM_DATAFRAME, x = ~OLD_MEASUREMENT, y = ~NEW_MEASUREMENT, color=~RESIDUAL,  colorscale = "Log",
               hovertext = paste("&lt;b&gt;New Measurement :&lt;/b&gt;", PARAM_DATAFRAME$NEW_MEASUREMENT,
                                 "&lt;br&gt;&lt;b&gt;Old Measurement :&lt;/b&gt;", PARAM_DATAFRAME$OLD_MEASUREMENT,
                                 "&lt;br&gt;&lt;b&gt;Residual :&lt;/b&gt;" , PARAM_DATAFRAME$RESIDUAL)) %&gt;% add_markers()
  
  #p &lt;- layout(p, color = list(type = "log"))
  p</code></pre>
  </div>
  </div>
  </p>
  
  <p>this is my current output:</p>
  
  <p><a href="https://i.stack.imgur.com/BK4SF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BK4SF.png" alt="enter image description here"></a></p>
  
  <p>I also tried the following code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>TEST_DATAFRAME = read.table(TEST_FILE, sep="\t",skip=2, header=T)
  PROD_DATAFRAME = read.table(PROD_FILE, sep="\t",skip=2, header=T)
  
  PARAMETER = "Vf_High"
  LST_RESIDUAL &lt;- PROD_DATAFRAME[PARAMETER] - TEST_DATAFRAME[PARAMETER]
  PARAM_DATAFRAME &lt;- data.frame("NEW_MEASUREMENT" = TEST_DATAFRAME[PARAMETER], 
                                "OLD_MEASUREMENT" = PROD_DATAFRAME[PARAMETER], 
                                "RESIDUAL" = abs(LST_RESIDUAL))
  
  colnames(PARAM_DATAFRAME) &lt;- c("NEW_MEASUREMENT","OLD_MEASUREMENT","RESIDUAL")
  
  brks &lt;- pretty(range(PARAM_DATAFRAME$RESIDUAL))
  gg &lt;- ggplot(PARAM_DATAFRAME, aes(NEW_MEASUREMENT, OLD_MEASUREMENT, color = RESIDUAL)) +
    geom_point() +
    scale_colour_gradient(
      low = "blue", high = "red",
      trans = "log", breaks = brks, labels = brks) +
    theme_minimal()
  
  ggplotly(gg)</code></pre>
  </div>
  </div>
  </p>
  
  <p>this is the result:</p>
  
  <p><a href="https://i.stack.imgur.com/oaucK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oaucK.png" alt="enter image description here"></a></p>
  
  <p>How can I give it legible labelling? 
  I want to configure the color bar as the following:</p>
  
  <p><a href="https://i.stack.imgur.com/acnDd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/acnDd.png" alt="enter image description here"></a></p>