# Editing subplot layouts (Adding shapes, drop-down menus)

**URL:** <https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519>\
**Category:** 📊 Plotly Python\
**Created:** [October 25, 2016, 9:17pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519 "2016-10-25T21:17:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertvl](https://avatars.discourse-cdn.com/v4/letter/r/54ee81/32.png) [@robertvl](https://community.plotly.com/u/robertvl)\
**Post date:** [October 25, 2016, 9:17pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519/1 "2016-10-25T21:17:56Z")

</div>

Is there a way to edit subplot layouts beyond modifying the axes? I know the layout for the entire figure can be accessed as a dictionary (e.g. fig[‘layout’]) but can a full layout dictionary be accessed for the subplots?

I would like to be able to use something like fig[‘layout’][‘subplot1layout’].update(shapes=[{‘type’: ‘rect’, ‘x0’: 0, ‘x1’: 1, ‘y0’: 0, ‘y1’: 1, ‘line’: {‘color’: ‘rgba(0, 0, 0, 1)’}}]

---

<div class="post-metadata">

**Author:** ![Adam](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/adam/32/23418_2.png) [@Adam](https://community.plotly.com/u/Adam)\
**Post date:** [October 26, 2016, 4:24pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519/2 "2016-10-26T16:24:17Z")

</div>

Hi there. Take a look at [this tutorial](https://plot.ly/python/subplots/#customizing-subplot-axes). It looks like you want to access the actual data in each subplot. That information is found in `data` in the `fig` object. So something like `fig['data'][0]` for one of the subplots.

---

<div class="post-metadata">

**Author:** ![andrea.botti](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@andrea.botti](https://community.plotly.com/u/andrea.botti)\
**Post date:** [April 5, 2017, 4:54pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519/3 "2017-04-05T16:54:30Z")

</div>

@Adam if willing to define a different shape for each subplot, would those need to be defined with the data or with with the layout?

---

<div class="post-metadata">

**Author:** ![Adam](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/adam/32/23418_2.png) [@Adam](https://community.plotly.com/u/Adam)\
**Post date:** [November 13, 2017, 8:38pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519/4 "2017-11-13T20:38:38Z")

</div>

Andrea,

I apologize for the late reply.

You would need to do it with the layout. Look at [this example](https://plot.ly/python/subplots/#multiple-subplots). The parameters `xaxis1`, `xaxis2`, etc are used to denote the domains of each of these axes. To change the subplot layout, change these values.

---

<div class="post-metadata">

**Author:** ![plexoos](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/plexoos/32/4678_2.png) [@plexoos](https://community.plotly.com/u/plexoos)\
**Post date:** [November 7, 2018, 9:29pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519/5 "2018-11-07T21:29:04Z")

</div>

For those who think the tutorials referenced above do not demonstrate how to draw shapes on subplots here is an example that worked for me:

```
import plotly.offline as ofl
import plotly.plotly as py
import plotly.tools as tls
import plotly.graph_objs as go

trace1 = go.Scatter(
    x=[10, 20, 30],
    y=[40, 50, 60]
)
trace2 = go.Scatter(
    x=[20, 30, 40],
    y=[50, 60, 70]
)
trace3 = go.Scatter(
    x=[30, 40, 50],
    y=[60, 70, 80]
)
trace4 = go.Scatter(
    x=[40, 50, 60],
    y=[70, 80, 90]
)
shapes = [
    {'type': 'line', 'x0': 25, 'y0': 100, 'x1': 35, 'y1': 100, 'xref': 'x1', 'yref': 'y1'},
    {'type': 'line', 'x0': 25, 'y0': 200, 'x1': 35, 'y1': 200, 'xref': 'x2', 'yref': 'y2'},
    {'type': 'line', 'x0': 25, 'y0': 300, 'x1': 35, 'y1': 300, 'xref': 'x3', 'yref': 'y3'},
    {'type': 'line', 'x0': 25, 'y0': 400, 'x1': 35, 'y1': 400, 'xref': 'x4', 'yref': 'y4'}
]

fig = tls.make_subplots(rows=2, cols=2)
fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 2)
fig.append_trace(trace3, 2, 1)
fig.append_trace(trace4, 2, 2)

fig['layout'].update(shapes=shapes)

ofl.iplot(fig, filename='multiple-subplots')
```

---

<div class="post-metadata">

**Author:** ![FoneMtl](https://avatars.discourse-cdn.com/v4/letter/f/f0a364/32.png) [@FoneMtl](https://community.plotly.com/u/FoneMtl)\
**Post date:** [June 30, 2019, 4:25pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519/6 "2019-06-30T16:25:46Z")

</div>

That was super useful thanks for clarifying @plexoos.

---

<div class="post-metadata">

**Author:** ![romdiaz](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@romdiaz](https://community.plotly.com/u/romdiaz)\
**Post date:** [October 28, 2020, 2:46pm UTC](https://community.plotly.com/t/editing-subplot-layouts-adding-shapes-drop-down-menus/2519/7 "2020-10-28T14:46:02Z")

</div>

This works excellent. I tried using add\_hlines first but col and row properties didnt work for me.
