I am a beginner in ggplot2
--it's been only 4 days since I have started experimenting with it. So, I apologize if this question sounds too basic. I'd appreciate any guidance--I've been struggling with this issue for about an hour.
I was experimenting with using geom_abline()
as below:
p <- ggplot(mpg, aes(cty, hwy)) + geom_point()
p + geom_abline() + facet_wrap(~cyl)
This works as in I can see a reference line in all four faceted graphs as below:
Later, I was using another related dataset mtcars
to see what happens to geom_abline()
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
p + geom_abline() + facet_wrap(~cyl)
However, when I ran this command, I couldn't see geom_abline().
Quite surprisingly, I found similar version of above command in the help file, and it says "geom_abline()
is out of the range"
While I know what "out of range" means, but how do I know whether in a particular dataset, abline()
will be out of range? I can override it by forcing it to use a specific slope and an intercept, but then I'd consider this a bit of hacking--i.e. modifying the code after seeing the output. Is there any way I can know what happens behind the scenes for geom_abline()
Here's the graph I got without any abline()
s
I'd appreciate any thoughts. I am really confused.