title: How do you add plot borders to Plotly subplots in R?
body: <p>I'm trying to make a grid of plots with shared axes, and I would like each subplot to have plot borders (it would be acceptable, though not ideal, for the entire plot area instead to have borders). I can't make this work, and the results make me think it may not be possible in Plotly. Below are the three variants I've tried, along with the outcomes.</p>
  
  <pre><code>    library(plotly)
      library(magrittr)
  
      set.seed(0)
      x &lt;- seq(from=0, to=9, by=1)
      y1 &lt;- rnorm(10)
      y2 &lt;- rnorm(10)
      y3 &lt;- rnorm(10)
      y4 &lt;- rnorm(10)
  
      # Attempt 1
      p1 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y1)
  
      p2 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y2)
  
      p3 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y3)
  
      p4 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y4)
  
      p &lt;- subplot(p1, p2, p3, p4,
                   nrows = 2, shareX = TRUE, shareY = TRUE) %&gt;%
        layout(title='Attempt 1', xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      # Attempt 2
      p1 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y1) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p2 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y2) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p3 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y3) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p4 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y4) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p &lt;- subplot(p1, p2, p3, p4,
                   nrows = 2, shareX = TRUE, shareY = TRUE) %&gt;%
        layout(title='Attempt 2')
  
      # Attempt 3
      p1 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y1) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p2 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y2) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p3 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y3) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p4 &lt;- plot_ly(showlegend=FALSE) %&gt;%
        add_markers(x = x, y = y4) %&gt;%
        layout(xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  
      p &lt;- subplot(p1, p2, p3, p4,
                   nrows = 2, shareX = TRUE, shareY = TRUE) %&gt;%
        layout(title='Attempt 3', xaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'),
               yaxis = list(showline = TRUE, mirror = TRUE, linecolor = 'black'))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/7Dm9E.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Dm9E.jpg" alt="Attempt 1"></a>
  <a href="https://i.stack.imgur.com/WOTE5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WOTE5.jpg" alt="Attempt 2"></a>
  <a href="https://i.stack.imgur.com/bQO8v.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bQO8v.jpg" alt="Attempt 3"></a></p>