Ethan Chen
Ethan Chen

Reputation: 1

Regression line goes out of box?

plot(pressure$temperature,pressure$pressure, 
     main = "Vapor Pressure of Mercury as a Function of Temperature", 
     ylim = c(0, 850), pch = 10)
regline <- lm(pressure$pressure ~ pressure$temperature)
cor(pressure$temperature, pressure$pressure)^2
abline(regline, col = "red")

My regression line goes out of the box and off the screen. How can I fix this?

Upvotes: 0

Views: 109

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226801

With 99% probability you set par(xpd=NA) at some point in your R session. From ?par:

‘xpd’ A logical value or ‘NA’. If ‘FALSE’, all plotting is clipped to the plot region, if ‘TRUE’, all plotting is clipped to the figure region, and if ‘NA’, all plotting is clipped to the device region. See also ‘clip’.

You can (1) use par("xpd") to see if that is the case; either (2a) start a clean session where you don't do that; or (2b) set par(xpd=FALSE) to reset the default.

Upvotes: 1

Related Questions