R:如何在绘图中设置y轴的弧度?

R:如何在绘图中设置y轴的弧度?,r,plot,trigonometry,R,Plot,Trigonometry,我想绘制两个向量(x和y)分数的弧tan: atan.add您可以在plot()函数中设置axes=FALSE,然后使用axis()定义自己的轴。比如: x <- 1:100 set.seed(121) y <- rnorm(5) #random data atan.add <- atan(x/y) plot(atan.add,axes=FALSE) #note the "axes=FALS

我想绘制两个向量(x和y)分数的弧tan:


atan.add您可以在
plot()
函数中设置
axes=FALSE
,然后使用
axis()
定义自己的轴。比如:

x <- 1:100            
set.seed(121)    
y <- rnorm(5)                     #random data
atan.add <- atan(x/y)
plot(atan.add,axes=FALSE)         #note the "axes=FALSE"
axis(side=1)                      #plot x axis (side=1)
axis(side=2, at=c(-pi, -pi/2, -pi/4, 0 ,pi/4, pi/2, pi), labels=expression(-pi, -pi/2, -pi/4, 0, pi/4, pi/2, pi))   #"side=2" specifies "y" axis

x
x正是我想要的。谢谢
x <- 1:100            
set.seed(121)    
y <- rnorm(5)                     #random data
atan.add <- atan(x/y)
plot(atan.add,axes=FALSE)         #note the "axes=FALSE"
axis(side=1)                      #plot x axis (side=1)
axis(side=2, at=c(-pi, -pi/2, -pi/4, 0 ,pi/4, pi/2, pi), labels=expression(-pi, -pi/2, -pi/4, 0, pi/4, pi/2, pi))   #"side=2" specifies "y" axis
x <- 1:20
set.seed(42)
y <- rnorm(20)
atan.add <- atan(x/y)
breaks_pi <- pretty(range(atan.add/pi))

plot(atan.add, yaxt="none")
axis(2, at = breaks_pi * pi, labels = paste(breaks_pi, "\u03c0"))