Setting the foreground color of colorbar tick marks

I am trying to make plot some data on black background, and setting fg_color to :white works well except for one details. The tick marks on the color bar remain black, and thus are rendered essentially invisible. The labels for each of the tick marks (the values) obey the fg_color setting, but not the tick marks themselves. I tried setting subplot_fg_color and that did not change anything. I also tried using some of the preset themes from PlotThemes but they all showed the same behavior.

Here is a small code sample with white background and red foreground to illustrate the issue

heatmap(0.01*randn(8,8), clim=(-1e-1,1e-1), c=:bam25)
plot!(
    size=(800,500),
    foreground_color=:red
)

with GR backend

with PythonPlot backend

I have not tried any other backend.

I also created an issue on Github but haven’t seen any replies.

Would something like this suit you:

1 Like

Yes! How do I get that?

Here’s the simple code used in the example above:

using Plots; gr()

data = 0.01*randn(8,8)
p1 = heatmap(data, c=:bam25, foreground_color=:red, colorbar=false)

data2 = collect(range(extrema(data)..., 100))
p2 = heatmap([1], data2, [data2;;], c=:bam25, fg_color=:red, colorbar=false, xaxis=false, ymirror=true)

l = @layout [a{0.95w} b]
plot!(p1, p2, layout=l, tick_direction=:out)

Great! This is a nice workaround for the short term that helps me a lot, but hopefully the bug also gets fixed.

More than a workaround, it can free the colorbar from its padlocks, opening up more possibilities for decorating it.

2 Likes