Black Lives Matter. Please consider donating to Black Girls Code today.
Dash Enterprise delivers an incredible 21x cost savings 💸Download the e-book!

Adding border to plot area

Assuming that the method to add a border around a plot in R works similarly to plotly.js (as here: Border around plot) it looks like it uses mirroring of the axes to apply the black border.


# x-axis layout
axx <- list(
            linecolor = "black",
            linewidth = 0.5,
            mirror = T

layout <- (xaxis = axx)

If I am using this method to add a black border, and then later do something like:

p <- subplot (p1, p2, nrows = 2, shareX = T)

(where p1 and p2 use the same x-axis layout) it doesn’t mirror the x-axes on all subplots so they don’t all have black borders. Do you have a solution to this? Thanks!

Do I have to not use shareX and instead specify different x-axis layouts, with p2 removing ticks and labels etc. to preserve the black border?