Home > Software engineering >  Axis range when using plot
Axis range when using plot

Time:05-17

Plot)

CodePudding user response:

This should do it:

x <- c(134.21, 139.12, 145.7, 148.81, 157.27, 128.4, 147.44, 133.72, 147.26, 137.26, 136.93, 137.37, 145.4, 141.74, 145.35, 130.01, 140.1, 136.3, 141.02, 137.5, 139.62, 140.05, 139.55, 135.55, 138.93, 140.07, 154.76, 138, 146.95, 139.62, 137.38, 146.27, 148.23, 152.65, 137.82, 145.28, 135.52, 152.97, 138.03, 138.82, 149.63, 131.83, 132.68, 151.5, 148.5, 142.79, 131.76, 132.83)
y <- c(0.0212, 0.1136, 0.0842, -0.0285, -0.1362, 0.1928, 0.0491, 0.0653, 0.0358, 0.082, -3e-04, 0.0659, -0.1173, -0.0707, -0.1298, 0.2789, 0.0092, 0.1105, -0.0603, 0.0409, 0.021, 0.0479, 0.0495, 0.1562, -0.1276, 0.0486, -0.519, 0.0548, 0.0072, 0.05, -0.0595, -0.0469, -0.1501, -0.2125, -0.0205, 0.0293, 0.0025, 3e-04, 0.0013, 0.0286, -0.1069, 0.1171, 0.1073, -0.0799, 0.0197, -0.0664, -0.0976, 0.0696 )
par(bg="black")
plot(x,y, xlim = c(125, 160), ylim = c(-0.6, 0.4), pch=21,bg="white",col="red",cex=2,lwd=1,col.lab="white",col.axis="white",cex.lab=1, col.main ="white", main="Scatterplot",font.main=1)
axis(1,col="white",col.axis="yellow")
axis(2,col="white",col.axis="yellow")
abline(lm(y~x),col="red",lwd=3)

enter image description here

  • Related