# Coloring part of the background with a specific color

**URL:** https://discourse.julialang.org/t/coloring-part-of-the-background-with-a-specific-color/131312
**Category:** Visualization
**Tags:** cairomakie
**Created:** [August 3, 2025, 5:15am UTC](https://discourse.julialang.org/t/coloring-part-of-the-background-with-a-specific-color/131312 "2025-08-03T05:15:26Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![imantha](https://avatars.discourse-cdn.com/v4/letter/i/6a8cbe/32.png) [@imantha](https://discourse.julialang.org/u/imantha)
#### Post date: [August 3, 2025, 5:15am UTC](https://discourse.julialang.org/t/coloring-part-of-the-background-with-a-specific-color/131312/1 "2025-08-03T05:15:26Z")

</div>

I am trying to color part of the background in in a plot with a specific color and unsure how to achieve it. In this case I want to color x \< 9 in grey and x\> 9 in orange.  
Any idea how to do it.

This is just adds the lines into the plot

```julia-auto
f = Figure()
ax = Axis(f[1,1])
for i = 1:size(gp_aggr,2)
    lines!(ax, 1:size(gp_aggr,1), gp_aggr[:,i], color = ("black",0.3))
end 

```

Here is equivalently what I want to be done in python. What I am looking for is the equivalent method to coloring the background using `.add_shape`

```julia-auto
p1 = px.line()
p1.add_scatter(x = df_lo["area"],y = df_lo["prev"], name = "actual low Rgns", mode = "lines")
p1.add_scatter(x = df_lo["area"],y = df_lo["prev_vae"], name = "preds low Rgns", mode = "lines")
p1.add_scatter(x = df_hi["area"], y = df_hi["prev"], name = "actual high Rgns")
p1.add_scatter(x = df_hi["area"], y = df_hi["prev_vae"], name = "preds high Rgns")
p1.add_shape(
    type="rect",
    x0=-1, x1=9, # Before x=9, low resolution region
    y0=-0.2, y1=1, # Cover the entire y-axis region
    fillcolor="gray", opacity=0.3, line_width=0 # Light blue background for low resolution
)
p1.add_shape(
    type="rect",
    x0=9, x1=58, # Before x=9, low resolution region
    y0=-0.2, y1=1, # Cover the entire y-axis region
    fillcolor="orange", opacity=0.3, line_width=0 # Light blue background for low resolution
)

p1.add_annotation(
    x=4.5, y=0.9, # Center the text over the low-resolution region
    text="Low Resolution Regions", # Label for low resolution
    showarrow=False,
    font=dict(size=12, color="black")
)

p1.add_annotation(
    x=30, y=0.9, # Center the text over the low-resolution region
    text="High Resolution Region", # Label for low resolution
    showarrow=False,
    font=dict(size=12, color="black")

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/6/961e7c74d4024d01769a42a2ede05976146b6074.png)

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [August 3, 2025, 5:43am UTC](https://discourse.julialang.org/t/coloring-part-of-the-background-with-a-specific-color/131312/2 "2025-08-03T05:43:37Z")

</div>

You could plot `Rect`s with `poly` but the more specialized function matching what you’re doing here is vspan [vspan | Makie](https://docs.makie.org/stable/reference/plots/vspan)
