# Set custom colorbar tick-labels

**URL:** <https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806>\
**Category:** Visualization\
**Tags:** question, plotting, plots\
**Created:** [October 15, 2021, 7:07am UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806 "2021-10-15T07:07:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![luraess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luraess/32/16189_2.png) [@luraess](https://discourse.julialang.org/u/luraess)\
**Post date:** [October 15, 2021, 7:07am UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806/1 "2021-10-15T07:07:20Z")

</div>

Hi, using `Plots.jl` and `GR` backend, how to set custom (text) colorbar tick-labels for each of the 5 color “bins” from this MWE

```julia
using Plots.jl
heatmap(rand(5,5), color=palette(:inferno, 5))

```

Thanks !

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 15, 2021, 8:20am UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806/2 "2021-10-15T08:20:15Z")

</div>

It doesn’t seem that this is currently possible with the Plots.jl gr() backend.

It might be feasible with the pyplot backend - [linking related thread.](https://discourse.julialang.org/t/plots-jl-colorbar-tick-labels/69632)

---

<div class="post-metadata">

**Author:** ![luraess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luraess/32/16189_2.png) [@luraess](https://discourse.julialang.org/u/luraess)\
**Post date:** [October 15, 2021, 8:28am UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806/3 "2021-10-15T08:28:56Z")

</div>

Thanks for the related links! Will check out the potential of the `pyplot` backend for that purpose. Could be a nice to have at some point.

---

<div class="post-metadata">

**Author:** ![jewh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jewh/32/28586_2.png) [@jewh](https://discourse.julialang.org/u/jewh)\
**Post date:** [March 17, 2022, 10:48am UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806/4 "2022-03-17T10:48:14Z")

</div>

Any update on whether this is possible with gr() yet?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [March 17, 2022, 9:18pm UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806/5 "2022-03-17T21:18:47Z")

</div>

Everything is possible, with some imagination:

 ![Plots_gr_discrete_colorbar_ticklabels](https://global.discourse-cdn.com/julialang/original/3X/9/3/930aa273620e8f2bb7327ea90dd289b465b488b6.png)

> **using Plots; gr()**
>
> ```julia
> using Measures, Plots; gr()
> 
> n = 5
> z = rand(10,10)
> clrticks = ["C$i" for i in 1:n]
> yt = range(0,1,n+1)[1:n] .+ 0.5/n
> 
> l = @layout [a{0.80w} [b{0.1h}; c] ]
> colors = cgrad(:inferno, n, categorical=true)
> p1 = heatmap(z, color=colors, cbar=false);
> p2 = plot([NaN], lims=(0,1), framestyle=:none, legend=false);
> annotate!(0.5, -0.1, text("Colors", 10, "Computer Modern"))
> xx = range(0,1,100)
> zz = zero(xx)' .+ xx
> p3 = heatmap(xx, xx, zz, ticks=false, ratio=10, legend=false, fc=colors, lims=(0,1),
> framestyle=:box, right_margin=20mm);
> [annotate!(1.5, yi, text(ti, 7, "Computer Modern")) for (yi,ti) in zip(yt,clrticks)]
> plot(p1, p2, p3, layout=l, margins=0mm)
> 
> ```

---

<div class="post-metadata">

**Author:** ![cmdenis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cmdenis/32/211517_2.png) [@cmdenis](https://discourse.julialang.org/u/cmdenis)\
**Post date:** [July 7, 2024, 1:57pm UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806/6 "2024-07-07T13:57:17Z")

</div>

Is this still not supported? It seems the GitHub issue has been in the same state for a while.

---

<div class="post-metadata">

**Author:** ![Wenzhe\_Ma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wenzhe_ma/32/13020_2.png) [@Wenzhe\_Ma](https://discourse.julialang.org/u/Wenzhe_Ma)\
**Post date:** [July 21, 2024, 3:56pm UTC](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806/7 "2024-07-21T15:56:46Z")

</div>

Hope the feature can be added soon.
