# How can I change the fontsize of the colorbar's label in Plots.jl?

**URL:** https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108
**Category:** Visualization
**Tags:** plots, statsplots
**Created:** [August 23, 2023, 11:31am UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108 "2023-08-23T11:31:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)
#### Post date: [August 23, 2023, 11:31am UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108/1 "2023-08-23T11:31:02Z")

</div>

Hi all, I have a 2D matrix that I want to plot as an heatmap. It is quite big though (58x58), so plotting it with

```julia
function pairwise_difference(v::Vector)::Matrix
    [x - y for x in v, y in v]
end

measures_vec = [t.mean * u"W" for t in results]
distance_matrix_measures = pairwise_difference(measures_vec)

p_measures = heatmap(
    [t.program for t in results],
    [t.program for t in results],
    distance_matrix_measures,
    c=cgrad([:green, :white, :red]),
    colorbar_title = "Error",
    colorbar_tickfontsize = 10,
    title="Differences between measured programs",
    aspect_ratio = :equal, yflip = true,
    xrotation = 90,
    xmirror = true,
    framestyle = :grid,
    size = (1_000, 1_000),
    grid = false,
)

```

gives very little labels:

 ![heatmap](https://global.discourse-cdn.com/julialang/original/3X/3/0/30afcb931e0a70f0ac5bec72aab5426e4ee8b7a7.png)  
Is there a way I can increase **the colorbar’s label font?** Thanks!

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [August 23, 2023, 2:26pm UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108/2 "2023-08-23T14:26:55Z")

</div>

You an scale all fonts with:

```julia
julia> scalefontsizes(1.3)

julia> heatmap(rand(100,100))

```

---

<div class="post-metadata">

### Author: ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)
#### Post date: [August 23, 2023, 3:59pm UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108/3 "2023-08-23T15:59:27Z")

</div>

Thanks! But apparently the signature is

```julia
scalefontsize(::Symbol, ::Number)

```

and the function is undocumented. What should I put there?

**EDIT** I noticed now that public function is plural, my bad.

---

<div class="post-metadata">

### Author: ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)
#### Post date: [August 23, 2023, 4:04pm UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108/4 "2023-08-23T16:04:57Z")

</div>

However, I’d like to only scale that font, and to keep the `xticksfontsize` fixed. Is there a way to only change that?

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [August 23, 2023, 5:38pm UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108/5 "2023-08-23T17:38:13Z")

</div>

You can use independently these keyword:

```julia
legendfontsize = 11 
xtickfontsize = 14 
ytickfontsize = 14
xguidefontsize = 14 
yguidefontsize = 14

```

These options are listed here: [Axis Attributes · Plots](https://docs.juliaplots.org/latest/generated/attributes_axis/)

---

<div class="post-metadata">

### Author: ![bertulli](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bertulli](https://discourse.julialang.org/u/bertulli)
#### Post date: [August 23, 2023, 5:52pm UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108/6 "2023-08-23T17:52:01Z")

</div>

You’re right, I asked you the wrong question. I wanted to say I’d like to change the **colorbar ticks’ font size** , which is apparently controlled by `yticksfontsize`. See this difference:

```julia
p_measures = heatmap(
    program_names,
    program_names,
    distance_matrix_measures,
    c=cgrad([:green, :white, :red]),
    colorbar_title = "Error",
    xtickfontsize = 5,
    ytickfontsize = 5,
    xguidefontsize = 400,
    yguidefontsize = 400,
    legendfontsize = 400,
    # xticks = (1:length(program_names), program_names),
    # yticks = (1:length(program_names), program_names),
    title="Differences between measured programs",
    aspect_ratio = :equal, yflip = true,
    xrotation = 90,
    xmirror = true,
    framestyle = :grid,
    size = (1_000, 1_000),
    grid = false,
)

```

giving

 ![heatmap](https://global.discourse-cdn.com/julialang/original/3X/b/a/ba06f1cd4fed6d2587da522b970afc71d4ffaa89.png)  
and

```julia
p_measures = heatmap(
    program_names,
    program_names,
    distance_matrix_measures,
    c=cgrad([:green, :white, :red]),
    colorbar_title = "Error",
    xtickfontsize = 5,
    ytickfontsize = 20, # <= HERE!
    xguidefontsize = 400,
    yguidefontsize = 400,
    legendfontsize = 400,
    # xticks = (1:length(program_names), program_names),
    # yticks = (1:length(program_names), program_names),
    title="Differences between measured programs",
    aspect_ratio = :equal, yflip = true,
    xrotation = 90,
    xmirror = true,
    framestyle = :grid,
    size = (1_000, 1_000),
    grid = false,
)

```

giving

 ![heatmap2](https://global.discourse-cdn.com/julialang/original/3X/e/2/e2f5dcf20173755e1f1b870302ddb3494560d9b6.png)

Should I open an issue?

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [August 23, 2023, 5:55pm UTC](https://discourse.julialang.org/t/how-can-i-change-the-fontsize-of-the-colorbars-label-in-plots-jl/103108/7 "2023-08-23T17:55:55Z")

</div>

> [@bertulli](#):
>
> Should I open an issue?

Probably, but I think that colorbar tick labels are already an open issue for other type of customizations. I even already manifested interest to contribute to that, but didn’t have time.
