# Add\_vrect not showing

**URL:** <https://community.plotly.com/t/add-vrect-not-showing/62497>\
**Category:** 📊 Plotly Python\
**Created:** [March 30, 2022, 4:55pm UTC](https://community.plotly.com/t/add-vrect-not-showing/62497 "2022-03-30T16:55:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cappers](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@cappers](https://community.plotly.com/u/cappers)\
**Post date:** [March 30, 2022, 4:55pm UTC](https://community.plotly.com/t/add-vrect-not-showing/62497/1 "2022-03-30T16:55:12Z")

</div>

Hi,  
i am trying to get a rectangle to be displayed in my plot and am having a few issues with its display. I have a subplot, with only 1 plot, but with a secondary axis showing a second dataset. I would like to show a rectangle on top of these plots showing the presence of a particular event. This rectangle doesn’t appear to display.  
My code is as follows:

```auto
#Create subplot with secondary axis
fig4 = make_subplots(specs=[[{"secondary_y": True}]])
#Add initial traces - NB. x and y values have been predefined from a pandas df
fig4.add_trace(go.Scattergl(x=SBAR_time_09, y=SBAR_Hz_Delta, mode='lines+markers', name='Eastings',line_color='magenta',connectgaps=False), secondary_y=False)
fig4.add_trace(go.Scattergl(x=SBAR_time_09, y=SBAR_FixT, name='Fix Type', line_color='red'), secondary_y=True)
#Add vrect
fig4.add_vrect(x0="12-09-2021 09:32:00",x1="12-10-2021 09:38:00",fillcolor="green", opacity=0.25, line_width=0)
fig4.update_yaxes(title_text='Fix Type', secondary_y=True)
fig4.update_yaxes(tickformat='digit')
fig4.update_layout(title_font=dict(size=22,color='black', family="Muli, sans-serif")
)

```

This gives me the plot shown below, everything is as expected, but i don’t get the rectangle.  
Any suggestions?  
Regards  
Dave

 ![odd_image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/c/d/cdc6c1cefbe20a74f3e562ee048779c4af520514.png)

---

<div class="post-metadata">

**Author:** ![some\_random\_dude](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@some\_random\_dude](https://community.plotly.com/u/some_random_dude)\
**Post date:** [April 10, 2022, 5:48pm UTC](https://community.plotly.com/t/add-vrect-not-showing/62497/2 "2022-04-10T17:48:09Z")

</div>

Did you try

```auto
from datetime import datetime

fig4.add_vrect(
x0=datetime.fromisoformat("12-09-2021 09:32:00"),
x1=datetime.fromisoformat("12-10-2021 09:38:00"),
fillcolor="green", opacity=0.25, line_width=0)

```
