Plots.jl | Heatmap legend is cut off or lays on top of the colorbar ticks

I am using the heatmap function in Plots.jl to plot densities in a plane. The colorbar should have a legend with an explanation “…”. I use the following code:

Heatmap = heatmap!(x,y,HeatmapData, c = :thermal,xlabel = “Local Time [h]”,ylabel = “Latitude [°]”,zlabel = “Density [particles / cm^3]”)

heatmap(titlefont=font(12,“Helvetica”),guidefont=font(12,“Helvetica”), labelfont=font(12,“Helvetica”), xtickfontsize=10,ytickfontsize=10,legendfont=(12,“Helvetica”),xticks=[0, 6, 12, 18, 24])

The plot looks like expected but the ticks of the colorbar are cut-off and so is the colorbar label. If I scale the numbers down it also occurs that the label lays on top of the ticks.

I appreciate your help!

1 Like

Try supplying a margin as a keyword argument, e.g. rightmargin=5Plots.mm .

One might think that Plots shoild handle this automatically, but from my understanding, writing a program which figures out how much space a piece of text will take is one of the hardest problems in CS.

1 Like