# Plots.jl GR add space between the colorbar and the colorbar\_title

**URL:** https://discourse.julialang.org/t/plots-jl-gr-add-space-between-the-colorbar-and-the-colorbar-title/66785
**Category:** General Usage
**Tags:** question, plotting, colorbar
**Created:** [August 21, 2021, 5:56pm UTC](https://discourse.julialang.org/t/plots-jl-gr-add-space-between-the-colorbar-and-the-colorbar-title/66785 "2021-08-21T17:56:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![josePereiro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josepereiro/32/17322_2.png) [@josePereiro](https://discourse.julialang.org/u/josePereiro)
#### Post date: [August 21, 2021, 5:56pm UTC](https://discourse.julialang.org/t/plots-jl-gr-add-space-between-the-colorbar-and-the-colorbar-title/66785/1 "2021-08-21T17:56:20Z")

</div>

Hi, how can I control the space between the colorbar and the colorbar\_title?

```julia
using Plots
p = heatmap(rand(100, 100);
    colorbar_title = "colorbar title",
    thickness_scaling = 1.6,
)
savefig(p, "test.png")

```

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

Im using:  
`julia 1.6.1`  
`Plots v1.19.3`  
`GR v0.58.0`

Thanks!

---

<div class="post-metadata">

### Author: ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)
#### Post date: [August 21, 2021, 11:19pm UTC](https://discourse.julialang.org/t/plots-jl-gr-add-space-between-the-colorbar-and-the-colorbar-title/66785/2 "2021-08-21T23:19:39Z")

</div>

Based on a quick glance at the code [here](https://github.com/JuliaPlots/Plots.jl/blob/54a6518d59498fb24b5c25a90cd91ceadb7e26de/src/args.jl), you’d expect to be able to play around with:

```julia
    :colorbar_titlefontsize => 10,
    :colorbar_title_location => :center, # also :left or :right
    :colorbar_titlefontfamily => :match,
    :colorbar_titlefonthalign => :hcenter,
    :colorbar_titlefontvalign => :vcenter,
    :colorbar_titlefontrotation => 0.0,

```

but it didn’t work for me. Perhaps another backend would help: `plotly()` sometimes has more options for tweaking than `gr()`. Inserting a line break in the title `\n` also didn’t work.

The best I can do for now is to resize the image. See the `size` argument. But then your thickness requirement is also diluted a little. So it’s not too different from reducing `thickness_scaling`. In other words, I can’t help very much, hopefully someone else will!

```julia
plot(st=:heatmap,
    rand(100, 100),
    colorbar_title="colorbar title",
    thickness_scaling=1.6,
    size=(1000,1000)
)

```

---

<div class="post-metadata">

### Author: ![genkuroki](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/genkuroki/32/18030_2.png) [@genkuroki](https://discourse.julialang.org/u/genkuroki)
#### Post date: [August 21, 2021, 11:33pm UTC](https://discourse.julialang.org/t/plots-jl-gr-add-space-between-the-colorbar-and-the-colorbar-title/66785/3 "2021-08-21T23:33:15Z")

</div>

```julia
using Plots
p = heatmap(rand(100, 100);
    colorbar_title = " \ncolorbar title",
    thickness_scaling = 1.6,
    right_margin = 2Plots.mm,
)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/2/1/2196259c4530e84eca0abeae70a8573fd023474f.jpeg)

Warning: The first blank of `" \ncolorbar title"` is not the ordinary blank `' '`.

---

<div class="post-metadata">

### Author: ![ptoche](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ptoche/32/23554_2.png) [@ptoche](https://discourse.julialang.org/u/ptoche)
#### Post date: [August 21, 2021, 11:45pm UTC](https://discourse.julialang.org/t/plots-jl-gr-add-space-between-the-colorbar-and-the-colorbar-title/66785/4 "2021-08-21T23:45:42Z")

</div>

Oh! I guess the linebreak is stripped if there is no string before it, so `"\nTitle"` fails but `" \nTitle"` works. Neat.

---

<div class="post-metadata">

### Author: ![josePereiro](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/josepereiro/32/17322_2.png) [@josePereiro](https://discourse.julialang.org/u/josePereiro)
#### Post date: [August 22, 2021, 6:10am UTC](https://discourse.julialang.org/t/plots-jl-gr-add-space-between-the-colorbar-and-the-colorbar-title/66785/5 "2021-08-22T06:10:51Z")

</div>

Clever, thanks!!!
