# Plots with log or symlog scale

**URL:** https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961
**Category:** Visualization
**Tags:** plots
**Created:** [October 6, 2018, 9:47am UTC](https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961 "2018-10-06T09:47:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [October 6, 2018, 9:47am UTC](https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961/1 "2018-10-06T09:47:47Z")

</div>

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))`  
gives

 ![image](https://global.discourse-cdn.com/julialang/original/3X/2/0/20567da3bc2c353922093d95aa597a9afc4c769d.png)  
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))`  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/1/01a655491ae2707ce1a8cbd5de21399cde67039b.png)  
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`:

```julia-auto
imshow(log.(abs.(A)), cmap=:RdBu)
colorbar()

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/f/0/f072613e3c36797274da489ec4d6c28ee2fe03e1.png)  
The same result as with `Plots`.  
With log-scale:

```julia-auto
imshow(abs.(A), cmap=:RdBu, norm=matplotlib[:colors][:LogNorm]())
colorbar()

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/8/18bb175c53e25e783cad9f0c51bdb6e965e727b6.png)  
This is the correct way to show log-scale plot.  
And finally, symlog:

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

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/3/a/3a2fb981de6fe730b44cfa4cc963ba293cc7d9b2.png)

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

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [October 6, 2018, 11:25am UTC](https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961/2 "2018-10-06T11:25:21Z")

</div>

There’s a Gadfly example here:

> [@histogram2d with logarithmic z-axis?](https://discourse.julialang.org/t/histogram2d-with-logarithmic-z-axis/9455/2):
>
> Yes in [Gadfly](http://gadflyjl.org/stable/): using RDatasets, Gadfly D = dataset("ggplot2","diamonds") p = plot(D, x=:Price, y=:Carat, Geom.histogram2d(xbincount=15, ybincount=15), Scale.color\_log10, Scale.x\_continuous(format=:plain), Guide.title("Diamonds") ) [diamonds]

---

<div class="post-metadata">

### Author: ![aplavin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aplavin/32/222056_2.png) [@aplavin](https://discourse.julialang.org/u/aplavin)
#### Post date: [October 6, 2018, 12:44pm UTC](https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961/3 "2018-10-06T12:44:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)
#### Post date: [October 7, 2018, 1:31am UTC](https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961/4 "2018-10-07T01:31:50Z")

</div>

Here is how far I got with [VegaLite.jl](https://github.com/fredo-dedup/VegaLite.jl):

```julia
df |> @vlplot(
  :rect,
  x={"x:o", title=nothing},
  y={"y:o", title=nothing, sort=:ascending},
  color={"v:q", title=nothing, scale={typ=:log}},
  width=400, height=200,
  config={
    view={stroke=:transparent},
    range={heatmap={scheme="redblue"}}
  }
)

```

And that gives me:  
 ![examp](https://global.discourse-cdn.com/julialang/original/3X/3/b/3bab67c148a6a93c458881fa56218296298390ba.png)

You would probably want to change how the [axis](https://vega.github.io/vega-lite/docs/axis.html) are shown, and probably also adjust the [color](https://vega.github.io/vega/docs/schemes/) range for the [scale](https://vega.github.io/vega-lite/docs/scale.html).

Symlog scales are not supported at this point, but something that the vega/vega-lite team has on their radar: [Add symlog axis scaling? · Issue #1392 · vega/vega · GitHub](https://github.com/vega/vega/issues/1392).

You can create interactive web charts with vega-lite, the documentation for that is [here](https://vega.github.io/vega-lite/docs/selection.html). 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](https://vega.github.io/vega-lite/usage/embed.html) to put that onto a webpage.

---

<div class="post-metadata">

### Author: ![jwtkeeble](https://avatars.discourse-cdn.com/v4/letter/j/34f0e0/32.png) [@jwtkeeble](https://discourse.julialang.org/u/jwtkeeble)
#### Post date: [November 25, 2025, 3:08pm UTC](https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961/5 "2025-11-25T15:08:39Z")

</div>

Has there been any updates on adding `symlog` to `Plots.jl`?

---

<div class="post-metadata">

### Author: ![briochemc](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/briochemc/32/4209_2.png) [@briochemc](https://discourse.julialang.org/u/briochemc)
#### Post date: [November 27, 2025, 1:49am UTC](https://discourse.julialang.org/t/plots-with-log-or-symlog-scale/15961/6 "2025-11-27T01:49:35Z")

</div>

Not sure about Plots.jl but [Makie + MakieExtra should work](https://juliaaplavin.github.io/MakieExtraDocs.jl/notebooks/examples.html#SymLog-and-asinh-scales). MWE:

```julia
using GLMakie, MakieExtra
A = randn(50, 100)
fig, ax, plt = heatmap(A; colorscale = SymLog(0.01), colormap = :RdBu)
Colorbar(fig[1, 2], plt; minorticks = BaseMulTicks(2:9), ticks = BaseMulTicks(1), minorticksvisible = true)

```

 ![symlogheatmap](https://global.discourse-cdn.com/julialang/original/3X/a/4/a4d8d2c011d7234bbb59e44b44a1f6e1e5b327a6.png)

[EDIT: In original post I manually made the minor ticks but MakieExtra has the `BaseMulTicks` function for exactly that so I updated the MWE and image.]
