Scaling axes in plots

Hi, To to test whether my regression model meets the assumption of homoscedasticity, I would like to perform a graphical analysis using a plot. This is what i did so far:

model <- lm(Umsatz~Patente+Marken+Konkordanz+MA+Arbeitsproduktivität, data=data_xls
plot(fitted.values(model),rstandard(model))
plot(model,1)
Then I got the first plot in the picture:

In order to be able to compare it with my other plot (the second plot on the picture) I would like to scale the axes similarily. Unfortunately, I could not figure out how to scale my x-axis from 18 to 25 and my y-axis from -0.5 to 1.5.

Would be very happy if someone could help me out here.

Thanks in advance!

I think you can use the xlim and ylim arguments of plot().

DF <- data.frame(Xval=18:25,Yval=18:25*3.4+rnorm(8))
model <- lm(Yval~Xval,data = DF)
plot(fitted.values(model),rstandard(model))

plot(fitted.values(model),rstandard(model),
     xlim = c(55,90),ylim = c(-2,2.5))

Created on 2021-10-11 by the reprex package (v2.0.1)

Thanks for your answer. I tried to use:

plot(fitted.values(model),rstandard(model),
xlim = c(55,90),ylim = c(-2,2.5))

This works for this plot just fine. But how do I get different axes for
plot(model,1) (meaning the plot including the red line)?
When I try the xlim and ylim arguments like this:

plot(model, 1),
xlim = c(55,90),ylim = c(-2,2.5))

I get this error:

plot(model,1),
Error: unexpected ',' in "plot(model,1),"
+ xlim = c(18,25),ylim = c(-0.5,1.5))
Error: unexpected ',' in " + xlim = c(18,25),"

you have 3 opening brackets and 4 closing brackets.
the first closing bracket after 1 should likely be removed

I treid this without the 4th clsoing bracket
> plot(model, 1,

  •  xlim = c(55,90),ylim = c(-2,2.5))
    

But I still get an error: Error in plot.default(yh, r, xlab = l.fit, ylab = "Residuals", main = main, :
formal argument "ylim" matched by multiple actual arguments

ok, ylim, is not a supported argument in the stats:::plot.lm format.
But you can follow the advice here and make your own version:
Setting ylim in R's plot.lm residual plot - Stack Overflow

The edit function fix("plotlm") does not work... I might just leave the axes like they are. Thanks for your help anyways :slight_smile: