# Setting figure with

**URL:** <https://community.plotly.com/t/setting-figure-with/22926>\
**Category:** Dash Python\
**Created:** [April 30, 2019, 2:13pm UTC](https://community.plotly.com/t/setting-figure-with/22926 "2019-04-30T14:13:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmartinis](https://avatars.discourse-cdn.com/v4/letter/c/9e8a1a/32.png) [@cmartinis](https://community.plotly.com/u/cmartinis)\
**Post date:** [April 30, 2019, 2:13pm UTC](https://community.plotly.com/t/setting-figure-with/22926/1 "2019-04-30T14:13:05Z")

</div>

Hello, I know this is an already solved problem but any solution is working for me.

I am generating an histogram in a callback like this:

```
layout = go.Layout(
        autosize=False,
        title=title,
        legend=dict(x=0, y=1.15, orientation="h")
    )

    return hg, go.Figure(data=data, layout=layout)

```

It updates the following graph:

```
histogram = dcc.Graph(id='histogram', style={
            'width':'100%',
            'height': '370px'
        }, config={'displayModeBar': False})

```

That is inside a div ( whose display attribute is toggled when needed):

`html.Div([html.H4('Histogram'),histogram],id='histogram_div',style = {"display": "none",'color':'black', 'width':'100%','height':'300px','margin':'0 auto'}),`

If I don’t specify the layout width, what I obtain is this:  
 ![Screenshot%20from%202019-04-30%2016-08-48](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/c/c63bfc9dfecc4acca15eff7552d45274caf86fcb.png)

If i resize the screen, the graph is updated to the desired width:  
 ![Screenshot%20from%202019-04-30%2016-09-39](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/3/3706e8b05d48555b2cf473801ecefce8ebc2adcc.png)

---

<div class="post-metadata">

**Author:** ![russellthehippo](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/russellthehippo/32/25312_2.png) [@russellthehippo](https://community.plotly.com/u/russellthehippo)\
**Post date:** [April 30, 2019, 3:34pm UTC](https://community.plotly.com/t/setting-figure-with/22926/2 "2019-04-30T15:34:20Z")

</div>

I’ve seen this pop up occasionally but haven’t heard of a solution. Similar problem here: [CSS grid causing dcc.Graph to resize incorrectly](https://community.plotly.com/t/css-grid-causing-dcc-graph-to-resize-incorrectly/22437)
