r - Using geom_abline() and ggplot -
i beginner in ggplot2
--it's been 4 days since have started experimenting it. so, apologize if question sounds basic. i'd appreciate guidance--i've been struggling issue hour.
i experimenting using geom_abline()
below:
p <- ggplot(mpg, aes(cty, hwy)) + geom_point() p + geom_abline() + facet_wrap(~cyl)
this works in can see reference line in 4 faceted graphs below:
later, using related dataset mtcars
see happens geom_abline()
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point() p + geom_abline() + facet_wrap(~cyl)
however, when ran command, couldn't see geom_abline().
quite surprisingly, found similar version of above command in file, , says "geom_abline()
out of range"
while know "out of range" means, how know whether in particular dataset, abline()
out of range? can override forcing use specific slope , intercept, i'd consider bit of hacking--i.e. modifying code after seeing output. there way can know happens behind scenes geom_abline()
here's graph got without abline()
s
i'd appreciate thoughts. confused.
if don't give arguments, geom_abline()
uses default values, intercept = 0
, slope = 1
.
ggplot(mpg, aes(cty, hwy)) + geom_point() + geom_abline() + lims(x = c(0,35), y = c(0,50)) ggplot(mtcars, aes(wt, mpg)) + geom_point() + geom_abline() + lims(x = c(0,6), y = c(0,35))
Comments
Post a Comment