Coloring part of the background with a specific color

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

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

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")

1 Like

You could plot Rects with poly but the more specialized function matching what you’re doing here is vspan vspan | Makie

2 Likes