# Layout not correct for plotlyjs backend

**URL:** <https://discourse.julialang.org/t/layout-not-correct-for-plotlyjs-backend/119567>\
**Category:** Visualization\
**Tags:** plots, plotlyjs\
**Created:** [September 18, 2024, 5:46pm UTC](https://discourse.julialang.org/t/layout-not-correct-for-plotlyjs-backend/119567 "2024-09-18T17:46:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arw](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@arw](https://discourse.julialang.org/u/arw)\
**Post date:** [September 18, 2024, 5:46pm UTC](https://discourse.julialang.org/t/layout-not-correct-for-plotlyjs-backend/119567/1 "2024-09-18T17:46:56Z")

</div>

The following code plots two subplots side-by-side. Works fine if you are using the gr backend but does not when using the plotlyjs backend. The first subplot spreads across the whole figure while the second subplot is positioned correctly and consequently hides half of the first subplot.

```julia
using Plots
l = @layout [a b]
for backend in [gr, plotlyjs]
	backend()
	p1 = plot(rand(10,2),seriestype=[:bar :scatter],layout=l)
	gui(p1)
end

```

Attached is a screenshot of how the plotlyjs version looks.

![plotlyjs_version_screenshot](https://global.discourse-cdn.com/julialang/original/3X/c/f/cf9afe5cfe48b15320a1c12431fb1d5f42f9c2d0.png)

However, if you use savefig and then look at the saved file, the plotlyjs version now looks correct. So it appears the problem is only in the visual display.  
Any help with this? I’m using julia 1.10.5.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [September 18, 2024, 5:56pm UTC](https://discourse.julialang.org/t/layout-not-correct-for-plotlyjs-backend/119567/2 "2024-09-18T17:56:25Z")

</div>

There seems to be [an open issue on this](https://github.com/JuliaPlots/Plots.jl/issues/1847).  
The workaround being to plot in a browser window via the `plotly()` backend instead of an electron window with `plotlyjs()`

---

<div class="post-metadata">

**Author:** ![arw](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@arw](https://discourse.julialang.org/u/arw)\
**Post date:** [September 18, 2024, 6:17pm UTC](https://discourse.julialang.org/t/layout-not-correct-for-plotlyjs-backend/119567/3 "2024-09-18T18:17:31Z")

</div>

If one is willing to use a browser window that workaround is OK. As the issue you link to was opened in 2018 I have little faith anyone is going to fix the root problem. I figured out another (not elegant) workaround: Make an empty plot and a position in the layout at the start with very narrow width:

```julia
l = @layout [a{0.001w} b c]
p0 = plot()
p1 = plot(rand(10,1),seriestype=[:bar])
p2 = plot(rand(10,1),seriestype=[:scatter])
p3 = plot(p0,p1,p2,layout=l)
gui(p3)

```
