# 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:** 1\
**Showing post:** 5

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

---

_[View the full topic](https://discourse.julialang.org/t/set-custom-colorbar-tick-labels/69806)._
