【问题标题】:Switching axis in multi-line plot在多线图中切换轴
【发布时间】:2016-06-22 13:36:09
【问题描述】:

您好,我有一个包含多条线的图,我想切换 x 轴和 y 轴。我怎么能做到?以下是我当前的情节代码

plot(ret,x1,type="l",col="blue",ylab="Volatility (%)",
xlab="Expected Return (%)",lwd=4, mgp=c(1.5, 0.5, 0))
lines(ret,x2,col="green",type="l",lwd=2)
lines(x3,col="black",type="l",lwd=4)

【问题讨论】:

    标签: r plot axis lines


    【解决方案1】:

    尝试在plot()和lines()中切换x和y参数:

    x <- 1:10
    y <- rnorm(10)
    plot(x, y, type = "l")
    plot(y, x, type = "l")
    lines(rnorm(10), x, type = "l", col = "blue")
    

    相应地更改 xlab 和 ylab...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-12-12
      • 1970-01-01
      • 1970-01-01
      • 2020-05-13
      • 2011-01-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多