# Reduce space between dcc.Graph and dcc.Slider

**URL:** <https://community.plotly.com/t/reduce-space-between-dcc-graph-and-dcc-slider/59820>\
**Category:** Dash Python\
**Created:** [January 5, 2022, 7:34pm UTC](https://community.plotly.com/t/reduce-space-between-dcc-graph-and-dcc-slider/59820 "2022-01-05T19:34:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ud.schn](https://avatars.discourse-cdn.com/v4/letter/u/898d66/32.png) [@ud.schn](https://community.plotly.com/u/ud.schn)\
**Post date:** [January 5, 2022, 7:34pm UTC](https://community.plotly.com/t/reduce-space-between-dcc-graph-and-dcc-slider/59820/1 "2022-01-05T19:34:29Z")

</div>

Hello, I created the following interactive graph in dash

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/a/3/a326886a6ab367ac83337f7871d24778b388a952.png)

As you see, the Slider is very far away from the graph. How do I shift the slider closer to the graph?  
Layout:

```
html.Div(
    [dcc.Slider(min=0,max=10,step=0.1,value=5,tooltip={"placement": "top", "always_visible": True},id = "importance_slider")],
    style = {'margin-left':55,'margin-right':55}
),
dcc.Graph(id = "time-series-chart",config= {'displaylogo': False}),

```

and the callback to the `dcc.Graph` is

```auto
    ....
    N = 10
    t = np.linspace(0,10,N)
    y = np.sin(t)

    fig = go.Figure(
            data = [go.Scatter(x=t,y=y,
                                 #colorscale="Cividis",
                                 marker = {"size": 25, "color": list(range(-3,10)), "cmid": 0},
                                 mode = "lines",
                                 fill = 'tozeroy'
                                 )],
            layout = go.Layout(
                                xaxis_title="Timeline",
                                yaxis_title="Importance",
                                paper_bgcolor='rgba(0,0,0,0)',
                                plot_bgcolor='rgba(0,0,0,0)',
                                # horizontal_spacing = 0.05,
                                # vertical_spacing = 0.05,
                                #autosize=False,
                                #width = 1000,
                                height = 300,                      
                                xaxis = {                                     
                                    'showgrid': True
                                            },
                                yaxis = {                              
                                    'showgrid': False,
                                    'zeroline': True, # thick line at x=0
                                    'visible': False, # numbers below
                                        },                                                        
                                )
    )
    fig.add_vline(x = ticker, line_width = 3, line_color = "red",opacity = 0.6) #line_dash = "dash",
    return fig

```

---

<div class="post-metadata">

**Author:** ![atharvakatre](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/atharvakatre/32/14713_2.png) [@atharvakatre](https://community.plotly.com/u/atharvakatre)\
**Post date:** [January 5, 2022, 9:57pm UTC](https://community.plotly.com/t/reduce-space-between-dcc-graph-and-dcc-slider/59820/2 "2022-01-05T21:57:05Z")

</div>

Hi @ud.schn

You can try changing the top margin of your graph. In your `go.Layout` function add another parameter `margin` which accepts a dictionary of margin values for top, bottom, left, right.

So here you can reduce the top margin of the graph by setting `margin=dict(t=5)`

Refer this for more info on using the margin attribute - [Setting Graph Size](https://plotly.com/python/setting-graph-size/)
