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

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

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:


Is there a way I can increase the colorbar’s label font? Thanks!

You an scale all fonts with:

julia> scalefontsizes(1.3)

julia> heatmap(rand(100,100))
1 Like

Thanks! But apparently the signature is

scalefontsize(::Symbol, ::Number)

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

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

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

You can use independently these keyword:

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

These options are listed here: Axis Attributes · Plots

1 Like

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:

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


and

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

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.

1 Like