# Setting the foreground color of colorbar tick marks

**URL:** <https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [November 21, 2024, 9:26pm UTC](https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911 "2024-11-21T21:26:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcusps](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcusps/32/537_2.png) [@marcusps](https://discourse.julialang.org/u/marcusps)\
**Post date:** [November 21, 2024, 9:26pm UTC](https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911/1 "2024-11-21T21:26:23Z")

</div>

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 `theme`s 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

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

```

with GR backend

 ![plotsjl_gr_colorbar_tickcolor](https://global.discourse-cdn.com/julialang/original/3X/7/a/7a0958c778b68b64f429597f914c3e8ce2329eac.png)

with PythonPlot backend

 ![plotsjl_pythonplot_colorbar_tickcolor](https://global.discourse-cdn.com/julialang/original/3X/9/c/9c35badcab2c9371a76d372edf392140c99e840b.png)

I have not tried any other backend.

I also [created an issue on Github](https://github.com/JuliaPlots/Plots.jl/issues/5030) but haven’t seen any replies.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 22, 2024, 12:09am UTC](https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911/2 "2024-11-22T00:09:58Z")

</div>

Would something like this suit you:

 ![Plots_colored_colorbar_tickmarks](https://global.discourse-cdn.com/julialang/original/3X/2/b/2b80f335d0b26748d952d0cb3f3c7abe9a7158eb.png)

---

<div class="post-metadata">

**Author:** ![marcusps](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcusps/32/537_2.png) [@marcusps](https://discourse.julialang.org/u/marcusps)\
**Post date:** [November 22, 2024, 1:21am UTC](https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911/3 "2024-11-22T01:21:14Z")

</div>

Yes! How do I get that?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 22, 2024, 6:44am UTC](https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911/4 "2024-11-22T06:44:52Z")

</div>

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

```julia
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)

```

---

<div class="post-metadata">

**Author:** ![marcusps](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marcusps/32/537_2.png) [@marcusps](https://discourse.julialang.org/u/marcusps)\
**Post date:** [November 22, 2024, 10:49pm UTC](https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911/5 "2024-11-22T22:49:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [November 22, 2024, 10:57pm UTC](https://discourse.julialang.org/t/setting-the-foreground-color-of-colorbar-tick-marks/122911/6 "2024-11-22T22:57:23Z")

</div>

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