title: How do you increase the space between the axis labels and axis titles in R using functions ggplot() and plot_ly?
body: <p>It appears that whenever I create graphs in R using the package <code>plotly</code>, the axis titles always cover the axis labels. I have 2 graphs now where this occurs. What code should I use to increase the space between the axis titles and labels using <code>plot_ly()</code> and <code>ggplot()</code>? And how do I ensure that the legend is visible in Plot 1 and not cut off?</p>
  
  <p>Previous StackOverflow questions give different ways to structure code but they just dont seem to work for my code.</p>
  
  <p>Plot 1:</p>
  
  <p><code>plot &lt;- ggplot(dat, aes(x=HeightUnderCWD, y=GrassHeight))+ geom_point()+
      labs(x = "Height under CWD (cm)", y = "Grass Height (cm)")+
      theme(text=element_text(size=20, family="Arial"))+
      stat_smooth(method = "lm",formula = y ~ x,se = FALSE, color='Darkgreen')+
      stat_smooth(aes(x = HeightUnderCWD, y = 7, linetype = "Linear Fit"), method = "lm", formula = y ~ x, se = FALSE,size = 1,color='lightgreen')
  ggplotly(plot)</code></p>
  
  <p><a href="https://i.stack.imgur.com/63rKx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/63rKx.png" alt="enter image description here"></a></p>
  
  <p>Plot 2:</p>
  
  <p><code>p&lt;-plot_ly(y = GrassHeight+1, color = CWDPosition,type = "box",colors = "Set1")%&gt;%
      layout(xaxis = x, yaxis = y, font = f)</code></p>
  
  <p><a href="https://i.stack.imgur.com/imgjH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/imgjH.png" alt="enter image description here"></a></p>