0

Here is a MWE:

library(ggplot2)

p<- ggplot(mtcars, aes(wt, mpg, color = factor(cyl))) +
geom_point() +
geom_smooth(method = "lm", formula = y~x)

Can someone please show me how to compute the dimensions of the plotted area ( that is the area which has the grey background NOT including the legend) ?

user2338823
  • 389
  • 1
  • 2
  • 11

1 Answers1

0

If I do not understand wrong the question, you are asking for the x and y limits of a graph. That can be set using: scale_x_continuous(limits = c(-10, 10)) or coord_cartesian(xlim = c(-10, 10)). It is answered here

Otherwise, if you are asking about the area created through the lines, that is the 95% confidence interval of your lm model. To see a better explanation, check here

Carles S
  • 2,388
  • 10
  • 23