Editing fontstyle for colorbar

I was trying to adjust the colorbar fonts in my heatmap, but I realized that there is no option to do so through PyPlot (or any other backend for that matter). I could just go back and call matplotlib directly, but that defeats the point when the functionality should exist.

For example, the matplotlib command plt.colorbar().set_label(label=‘a label’,size=15) could be given as cb:set_label
(Currently if you try this Julia throws an error for too many arguments)
Likewise, the colorbar ticks could be adjusted as follows:

I would try to fix these things myself, but I do not under fully where PyPlot is making explicit calls to matplotlib and how to adjust those. Help with either resolving this or pointing me in the right direction would be appreciated.

1 Like

When you talk about “backends”, does that mean you’re working with Plots.jl? You only mention PyPlot.

Correct, I’m trying to use Plots.jl with PyPlot as a backend.

By adding the following lines when the colorbar is created (line 863 in pyplot.jl under backends in the Plots package) I am able to adjust the font size and family of the colorbar tick labels based on the Y-axis fontsize (:ytickfont), though I suppose in the future this should be independent of other axes.

axis = sp[Symbol(:y,:axis)]
cbax = fig[:add_axes]([0.8,0.1,0.03,0.8], label = string(gensym()))
 cb = fig[:colorbar](handle; cax = cbax, kw...)
 cb[:set_label](sp[:colorbar_title],size=py_dpi_scale(plt, axis[:guidefont].pointsize),family=axis[:guidefont].family)
for lab in cb[:ax][:yaxis][:get_ticklabels]()
       lab[:set_fontsize](py_dpi_scale(plt, axis[:tickfont].pointsize))

Similarly for the colorbar label I use:guidefont as the formatter. This sets the size and font accurately, though I am unsure on efficiency.