How to plot contours with a log scale in an interactive graph in R?
<p>I have a contour plot displayed with plotly:</p>

<pre><code>x &lt;- rep(seq(0.01, 0.1, length.out = 50), 50)
y &lt;- rep(seq(0.01, 0.1, length.out = 50), each = 50)
z &lt;- 1 / (x^2 + y^2)

my.data &lt;- data.frame(x, y, z)

p &lt;- plot_ly(data = my.data, x = x, y = y, z = z, type = "contour")
</code></pre>

<p>Here is the result:</p>

<p><a href="https://i.stack.imgur.com/7S4le.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7S4le.png" alt="No log scale"></a></p>

<p><strong>Question:</strong> How to use a log scale for the z colors? Or how to manually control the contour levels?</p>

<p>I tried <code>layout(p, zaxis = list(type = "log"))</code> but it does not work.</p>

<p><strong>Remark #1:</strong> I don't want to plot <code>log(z)</code>, which is the obvious solution, but to have a log color scale.</p>

<p><strong>Remark #2:</strong> if it's not possible with plotly, what interactive graph library can do it? I need a library that exports my graph to an html file.</p>

<p><strong>Remark #3:</strong> I tried plotting with ggplot in log scale and then using the ggplotly command, but in the end, plotly just plots log(z).</p>

<p><strong>Remark #4:</strong> I tried with heat maps, manually setting the colour scale as indicated <a href="https://plot.ly/r/heatmaps/" rel="nofollow noreferrer">here</a>, but could not make it work.</p>