title: R: Making Axis Consistent in ggplot
body: <p>I am working with the R programming language.</p>
  <p>I generated some random data and added a polynomial regression line to the data:</p>
  <pre><code># PLOT 1
  
  library(ggplot2)
  
  x = rnorm(15, 2,2)
  
  y = rnorm(15,7,2)
  
  df = data.frame(x,y)
  
  p &lt;-ggplot(df, aes(x, y))
  
  p &lt;- p + geom_point(alpha=2/10, shape=21, fill=&quot;blue&quot;, colour=&quot;black&quot;, size=5)
  
  #Add a loess smoother
  
  p + stat_smooth(method=&quot;lm&quot;, se=TRUE, fill=NA, formula=y ~ poly(x, 6, raw=TRUE),colour=&quot;red&quot;) + ggtitle(&quot;Original Data: Polynomial Regression Model&quot;)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/qeNL0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qeNL0.png" alt="enter image description here" /></a></p>
  <p>Now, I want to add a single outlier to this data, re-fit the polynomial regression and plot the data:</p>
  <pre><code># PLOT 2
  
  x = rnorm(1,13,1)
  
  y = rnorm(1, 13,1)
  
  df_1 = data.frame(x,y)
  
  df = rbind(df, df_1)
  
  p &lt;-ggplot(df, aes(x, y))
  
  p &lt;- p + geom_point(alpha=2/10, shape=21, fill=&quot;blue&quot;, colour=&quot;black&quot;, size=5)
  
   #Add a loess smoother
  
  p + stat_smooth(method=&quot;lm&quot;, se=TRUE, fill=NA,
  
                  formula=y ~ poly(x, 6, raw=TRUE),colour=&quot;red&quot;) +  ggtitle(&quot;Modified Data: Polynomial Regression Model&quot;)
  </code></pre>
  <p><strong>My Problem:</strong> The problem is, now the axis has become so big that the data looks like a &quot;flat line&quot;:</p>
  <p><a href="https://i.stack.imgur.com/R9QU0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R9QU0.png" alt="enter image description here" /></a></p>
  <p>I tried to fix this by limiting the size of the axis:</p>
  <pre><code>p + stat_smooth(method=&quot;lm&quot;, se=TRUE, fill=NA, formula=y ~ poly(x, 6, raw=TRUE),colour=&quot;red&quot;) +  ggtitle(&quot;Modified Data: Polynomial Regression Model&quot;)+ scale_y_continuous(limits = c(min(df$y),max(df$y)))
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Ia3ye.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ia3ye.png" alt="enter image description here" /></a></p>
  <p>But I now get the following warning message:</p>
  <pre><code>Warning message:
  Removed 35 rows containing missing values (geom_smooth). 
  </code></pre>
  <p><strong>My Question:</strong> Why are rows being deleted when I try to fix the axis? Is there a better way to correct this problem?</p>
  <p>Thanks!</p>