Plots with log or symlog scale

I’m trying to make plots with log and symlog scales, but no success with Plots.jl so far. When I try cgrad(scale=:log) it gives strange results, see below. And there seem to be no other place to specify log-scale.

A = randn(50, 100)
heatmap(log10.(abs.(A)), color=cgrad(:RdBu))
which has correct colors, but of course wrong color scale: I need it to show original values instead of logs.
With scale=:log:
heatmap(abs.(A), color=cgrad(:RdBu, scale=:log))
I totally don’t get how it computes colors here. And also I don’t find anything related to symlog scale.

For comparison, using PyPlot:

imshow(log.(abs.(A)), cmap=:RdBu)

The same result as with Plots.
With log-scale:

imshow(abs.(A), cmap=:RdBu, norm=matplotlib[:colors][:LogNorm]())

This is the correct way to show log-scale plot.
And finally, symlog:

imshow(A, cmap=:RdBu, norm=matplotlib[:colors][:SymLogNorm](1e-2))


Is there a way to reproduce the last two plots (which use PyPlot) with Plots and non-pyplot backend?

1 Like

There’s a Gadfly example here:

But what about Plots.jl? I’m looking for an interactive web plot, using plotly backend.

1 Like

Here is how far I got with VegaLite.jl:

df |> @vlplot(
  x={"x:o", title=nothing},
  y={"y:o", title=nothing, sort=:ascending},
  color={"v:q", title=nothing, scale={typ=:log}},
  width=400, height=200,

And that gives me:

You would probably want to change how the axis are shown, and probably also adjust the color range for the scale.

Symlog scales are not supported at this point, but something that the vega/vega-lite team has on their radar:

You can create interactive web charts with vega-lite, the documentation for that is here. It is quite different from plotly, so not sure it would match your needs. But you should be able to export the vega-lite spec with yourspec |> save("foo.vegalite") and then follow the instructions for vega-lite embedding to put that onto a webpage.