# Plot in Pluto.jl made with the plotly backend has a lot of wasted white space

**URL:** <https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681>\
**Category:** General Usage\
**Tags:** plotting, pluto\
**Created:** [December 6, 2021, 9:20pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681 "2021-12-06T21:20:09Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrapoci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultrapoci/32/25356_2.png) [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Post date:** [December 6, 2021, 9:20pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/1 "2021-12-06T21:20:09Z")

</div>

I’ve made a simple plot in Pluto.jl with the `plotly()` backend, but as you can see from the picture, it has a lot of white space on its left. The cells in Pluto are already pretty small, and this makes the plot even smaller. Is there a way to change this? With the `gr()` backend this doesn’t happen, but I’d like to keep using `plotly()` due to its interactivity.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/5/554ed61174e9654d8c1b67e4a7c7a83215a34a33.png)

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 6, 2021, 10:03pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/2 "2021-12-06T22:03:41Z")

</div>

You can always pass the option `size = (700, 400)` or something to adjust the size of the plot. You can also pass this option in the first cell of the notebook so that it becomes the default:

```julia
plotlyjs(size = (700, 400))

```

---

<div class="post-metadata">

**Author:** ![ultrapoci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultrapoci/32/25356_2.png) [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Post date:** [December 7, 2021, 8:52am UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/3 "2021-12-07T08:52:44Z")

</div>

This makes it possible to have the plot fit inside the cell, but doesn’t remove the white space. When making it wider, it extends it to the right, forcing me to have to scroll to the right to see other parts of the plot. I can make it smaller, but now I have a tiny plot. If I could somehow tell Pluto or plotly to start drawing the plot all the way to the left, removing the white space, I could have a bigger plot that fits inside the cell nicely.

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [December 7, 2021, 10:29am UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/4 "2021-12-07T10:29:27Z")

</div>

I do not seem to have your white border behavior with a simple example I just tried:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/8/c8d0a1eebf5b9b14679ce46b77dd78790dd1ded8.png)

Can you try if with this simple plot you also have no whitespace on the left of the plot (so it depends on your specific plot data) or if you still have it and then it may be due to a difference in Pluto or Plots version?

For reference I am using latest Plots (1.25.0) and latest Pluto (0.17.3)

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 7, 2021, 11:07am UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/5 "2021-12-07T11:07:43Z")

</div>

Can you confirm this behavior happens with Plotly.jl and PlotlyJS.jl backends? I don’t know if there is a real difference, but I am only familiar with PlotlyJS.jl which is the offline version.

---

<div class="post-metadata">

**Author:** ![ultrapoci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultrapoci/32/25356_2.png) [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Post date:** [December 7, 2021, 12:07pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/6 "2021-12-07T12:07:18Z")

</div>

I’ve updated just now Pluto from 0.17.2 to 0.17.3, but it didn’t change the behaviour. With that said, I’ve tried the same example as you did, and no white space is present. I’ve discovered that if the number of points is small enough, the white space is not there. If I increase the number of points, the white space appear. Here is a gif showing this:

![ezgif-3-d7a1481409bb](https://global.discourse-cdn.com/julialang/original/3X/4/f/4f5fb364f5f965d04028e0e7c570805569949ae1.gif)

I’ve disabled everything from `plot()` except the array of points, which is a simple Int64 array, as you can see from the end of the gifs. Not sure why this is the case.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [December 7, 2021, 12:23pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/7 "2021-12-07T12:23:47Z")

</div>

The issue seems related to the ylabels in scientific notation. Whenever they change to scientific notation you get extra white space. Can you try fixing the format of the labels to avoid scientific notation and see if the issue is still present? Worth reporting on GitHub.

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [December 7, 2021, 1:00pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/8 "2021-12-07T13:00:13Z")

</div>

This does not seem to be a problem inherent to the ploltyjs library (Which is called by both Plotly.jl and PlotlyJS.jl by relying on PlotlyBase.jl).  
I tried to reproduce the same scientific notation using PlotlyBase.jl and looking at the metadata of the plot object in the cell HTML (using the browser developer console):

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/1/61db3cb030c215091086b7472335ba014efacfc2.png)

So it does indeed seem to come out of some processing that happens between the call to `plot` and the translation to the plotly HTML code.

---

<div class="post-metadata">

**Author:** ![ultrapoci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultrapoci/32/25356_2.png) [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Post date:** [December 7, 2021, 1:06pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/9 "2021-12-07T13:06:40Z")

</div>

I’m using `yticks = :native`, which removes the scientific notation, but keeps the shorthand notation for long numbers (e.g. 35000 becomes 35k) and the problem is the same. Something is going on when the y axis labels get converted into other notations.

EDIT: in `plot()`, using `yformatter = :scientific` or `yformatter = :auto` makes the white space appear, while using `yformatter = :plain` the white space _doesn’t_ appear.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 7, 2021, 1:17pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/10 "2021-12-07T13:17:27Z")

</div>

This should be looked into properly of course, but as a workaround does `yformatter = x -> x/1e6` (or whatever scale you need) help?

---

<div class="post-metadata">

**Author:** ![ultrapoci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ultrapoci/32/25356_2.png) [@ultrapoci](https://discourse.julialang.org/u/ultrapoci)\
**Post date:** [December 7, 2021, 1:18pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/11 "2021-12-07T13:18:40Z")

</div>

It does, using a custom `yformatter` solves the problem. Apparently, `:scientific` and `:auto` values add additional white space to the left.

---

<div class="post-metadata">

**Author:** ![disberd](https://avatars.discourse-cdn.com/v4/letter/d/8edcca/32.png) [@disberd](https://discourse.julialang.org/u/disberd)\
**Post date:** [December 7, 2021, 2:02pm UTC](https://discourse.julialang.org/t/plot-in-pluto-jl-made-with-the-plotly-backend-has-a-lot-of-wasted-white-space/72681/12 "2021-12-07T14:02:12Z")

</div>

To help some troubleshooting if you file an issue on Plots, it seems the problem lies in the computation and definition of the `domain` variable of the `xaxis` plot property, which defines the start and end position (relative to the plot figure) of the x-axis:

![image](https://global.discourse-cdn.com/julialang/original/3X/e/7/e7fcef245516da6b5be51fb3629ceb16929db821.png)

For some reason when the scientific notation triggers this domains get pushed all the way to 0.27 as starting point (for the example of plotting `rand(10) .* 1e8`).
