R ggplot2 scale_y_continuous : Combining breaks & limits
<p><strong>Problem</strong>: I cannot find any way to combine the breaks and limits commands in <code>ggplot2</code>. The y-axis should always contain the range of 0-40 and <code>breaks=c(5,10,15,20,25,30,35)</code>. The x-axis should be 0-100, <code>breaks=c(10,20,30,40,50,60,70,80,90,100)</code>. I do NOT want to display data that is outside this range. </p>

<p>I tried <code>+ ylim</code>, but this overwrites my breaks.
I tried <code>+ expand</code>, but this also shows data outside the range that I want(1-100).
I tried both adding the breaks and limiting the range in a second step, but the y-axis of my first step is simply overwritten if I do that.</p>

<pre><code>plot_Tili_Age_VS_Height &lt;- ggplot(Tili, aes(x = Age, y = Height)) + geom_point() + 
  geom_smooth(method = "lm", se = FALSE, color = "black", formula = y ~ x) + 
  scale_y_continuous(trans = "log10", breaks = c(5, 10, 15, 20, 25, 30, 35)) + 
  expand_limits(y = c(0, 35), x = c(0, 100)) + 
  scale_x_continuous(trans = "log10", breaks = c(10, 20, 30, 40, 50, 60,70, 80, 90, 100)) +
  theme_bw(base_size = 15) + 
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

df &lt;- data.frame(x = log(Tili$Age), y = log(Tili$Height))
lm_eqn = function(df) {
  m = lm(y ~ x, df)
  eq &lt;- substitute(ln(italic(y)) == a + b %*% ln(italic(x)) * "," ~ ~italic(r)^2 ~ 
                     "=" ~ r2, list(a = format(coef(m)[1], digits = 2), 
                                    b = format(coef(m)[2], digits = 2), 
                                    r2 = format(summary(m)$r.squared, digits = 2)))
  as.character(as.expression(eq))
}

plot_Tili_Age_VS_Height &lt;- plot_Tili_Age_VS_Height + 
  annotate("text", x = 30, y = 5, label = lm_eqn(df), hjust = 0, 
           size = 3, family = "Times", parse = TRUE)
plot_Tili_Age_VS_Height 
</code></pre>

<p>Any idea how to fix it?</p>