# Get rid of whitespace either side of plot (inside axis)

**URL:** <https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659>\
**Category:** plotly.js\
**Created:** [April 13, 2018, 8:43am UTC](https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659 "2018-04-13T08:43:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmoir](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmoir/32/2959_2.png) [@jmoir](https://community.plotly.com/u/jmoir)\
**Post date:** [April 13, 2018, 8:43am UTC](https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659/1 "2018-04-13T08:43:28Z")

</div>

![03](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/6/6c1988d805473e41c70ad1f8fa67aa2474d37439.png)  
As can be seen in the image above, there is a white space in-between the actual bars/lines of the plot and the axis.

I’ve looked through the options and it seems that padding is the closest option I can find, but it is already set to 0. Is there anything that can be done to amend this?

Please & thank you.

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [April 13, 2018, 2:21pm UTC](https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659/2 "2018-04-13T14:21:39Z")

</div>

I think you’re looking for [`xaxis.range`](https://plot.ly/javascript/reference/#layout-xaxis-range) or maybe `margin.l` and `margin.r`.

---

<div class="post-metadata">

**Author:** ![jmoir](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmoir/32/2959_2.png) [@jmoir](https://community.plotly.com/u/jmoir)\
**Post date:** [April 16, 2018, 12:56am UTC](https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659/3 "2018-04-16T00:56:25Z")

</div>

@etienne Ahh, xaxis.range. I’ll give that a god thanks!

I’ve tried changing the margins (Y)

---

<div class="post-metadata">

**Author:** ![jmoir](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmoir/32/2959_2.png) [@jmoir](https://community.plotly.com/u/jmoir)\
**Post date:** [April 16, 2018, 1:53am UTC](https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659/4 "2018-04-16T01:53:05Z")

</div>

xaxis.range worked perfectly, thanks!

---

<div class="post-metadata">

**Author:** ![Mike3](https://avatars.discourse-cdn.com/v4/letter/m/e99b99/32.png) [@Mike3](https://community.plotly.com/u/Mike3)\
**Post date:** [October 26, 2018, 6:30am UTC](https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659/5 "2018-10-26T06:30:32Z")

</div>

Hello, jmoir. I have a similar issue with my graphs. Could you potentially share the xaxis.range code you used that fixed the issue? As trivial as it is, I’m encountering issues getting it to work.

---

<div class="post-metadata">

**Author:** ![filipesmg](https://avatars.discourse-cdn.com/v4/letter/f/e47c2d/32.png) [@filipesmg](https://community.plotly.com/u/filipesmg)\
**Post date:** [December 2, 2022, 10:29am UTC](https://community.plotly.com/t/get-rid-of-whitespace-either-side-of-plot-inside-axis/9659/6 "2022-12-02T10:29:12Z")

</div>

I will bring back this issue instead of creating a new one, since I have a similar issue: When I add markers, the graph has the white spaces on the edges (which does not happen when I use `type: line`). I can fix that with the `xaxis.range`, but when I zoom and then double click, it goes back to the case with white spaces. Is there any solution to set the “home” zoom as the one without the whitespaces?
