# Shapes - update layout

**URL:** <https://community.plotly.com/t/shapes-update-layout/72299>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [February 4, 2023, 6:06pm UTC](https://community.plotly.com/t/shapes-update-layout/72299 "2023-02-04T18:06:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![plotmaster422](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/plotmaster422/32/22680_2.png) [@plotmaster422](https://community.plotly.com/u/plotmaster422)\
**Post date:** [February 4, 2023, 6:06pm UTC](https://community.plotly.com/t/shapes-update-layout/72299/1 "2023-02-04T18:06:30Z")

</div>

I am shading the confidence interval of a probability density function (PDF) and noticing that the update\_layout(shapes) doesn’t allow shading of the Area Under the Curve (AUC). I am confused as to why this isn’t enabled by default. My environment has plotly==5.11.0 and dash==1.21.0.

Here is my code:

> def hist\_box(continuous):
> 
> ```
> # statistics measurements
> x_bar = continuous.mean()
> s = continuous.std()
> n = continuous.size
> se = s / np.sqrt(n)
> dof = n - 1
> 
> density = np.linspace(continuous.min(), continuous.max(), 100)
> pdf = norm.pdf(density, x_bar, s)
> ci = ta.interval(0.95, df=dof, loc=x_bar, scale=(s / np.sqrt(n)))
> 
> # subplot 1/2
> ff = go.Figure()
> 
> ff.add_trace(
> go.Histogram(
> dict(
> x=continuous,
> histfunc="count",
> histnorm="probability density",
> marker={"color": "rgba(4, 217, 255, 255)"},
> opacity=0.73,
> ),
> name=continuous.name.title() + " "
> )
> )
> 
> ff.add_trace(
> go.Scatter(
> dict(
> x=density,
> y=pdf,
> mode="lines",
> marker={"color": "rgba(4, 217, 255, 255)"},
> showlegend=False
> )
> )
> )
> 
> # subplot 2/2
> fg = go.Figure()
> 
> fg.add_trace(
> go.Box(
> x=continuous,
> showlegend=False,
> marker={"color": "rgba(4, 217, 255, 255)"},
> name=""
> )
> )
> 
> # final figure
> final_fig = make_subplots(
> rows=4,
> cols=1,
> specs=[
> [{"type": "scatter", "rowspan": 3}],
> [None], [None],
> [{"type": "box", "rowspan": 1}]
> ],
> shared_xaxes="all"
> )
> 
> # add data to trace
> for t in ff.data:
> final_fig.add_trace(t, row=1, col=1)
> for t in fg.data:
> final_fig.add_trace(t, row=4, col=1)
> 
> # layout fails, must put shape on rows, cols
> final_fig.update_layout(
> dict(
> font={"family": "Lato", "color": "#979797"},
> paper_bgcolor="#111111",
> plot_bgcolor="#1e1e1e",
> title=dict(
> text=f"Distribution of {continuous.name.title()}",
> font={"size": 28.5, "color": "rgba(255, 255, 255, 155)"},
> x=0.5,
> ),
> legend=dict(
> title=dict(
> text=" <b>Variable</b>"),
> x=0.01,
> y=0.97,
> bgcolor="#292929",
> font={"color": "#e1e1e1"}
> ),
> xaxis=dict(
> showticklabels=True,
> zeroline=False,
> showgrid=False
> ),
> yaxis=dict(
> title=dict(
> text="Probability Density"),
> zeroline=bool(False),
> showgrid=bool(False),
> range=[0, pdf.max() * 1.21],
> ),
> xaxis2=dict(
> showticklabels=False,
> zeroline=False,
> showgrid=False
> ),
> yaxis2=dict(
> zeroline=False,
> showgrid=False),
> )
> ).add_shape(
> dict(
> line=dict(width=0),
> type="rect",
> xref="x1",
> yref="paper",
> fillcolor="rgba(167, 245, 233, 255)",
> x0=ci[0],
> x1=ci[1],
> y0=0,
> y1=pdf.max(),
> opacity=0.5,
> ),
> row=1,
> col=1
> )
> 
> return final_fig
> 
> ```
> 
> cont = x  
> final\_fig = hist\_box(cont)  
> plot(final\_fig)

The resulting plot. The shaded region overshadows the PDF curve.

 ![newplot (17)](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/0/4/04b56e2eb7b867cc38a321ee9f7aac3807b7c760.png)

The ideal solution shades between x0 and x1, with y1 based on an existing trace.

---

<div class="post-metadata">

**Author:** ![plotmaster422](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/plotmaster422/32/22680_2.png) [@plotmaster422](https://community.plotly.com/u/plotmaster422)\
**Post date:** [February 7, 2023, 2:21pm UTC](https://community.plotly.com/t/shapes-update-layout/72299/2 "2023-02-07T14:21:03Z")

</div>

any update on this ? seems like a relatively straightforward implementation, add the y1 as a “fill between” that works with a preexisting trace.

For future implementations, my exact solution would be to augment “tonexty” to consider x params as well as a graphic object. But this may be more complicated.
