由线条功能生成的绘图线未显示在闪亮的绘图输出上

时间:2019-04-03 03:17:22

标签: r plot shiny

我有一个函数来调用图,然后是线条,然后是图例。然后,输出将显示在“闪亮”页面上。 问题在于,虽然情节和图例都显示,但线条却不显示。

这是给R的Shiny用的。

# helper function
myFunction <- function() {
  # plot shows fine
  plot(x=20,
       y=0.4,
       ylab="probability",
       ylim=c(0,1),
       xlab="X axis",
       type="l",
       lty="solid",
       col="blue")

  # lines do not show
  lines(20, 0.5,lty="dashed", col="red")

  # legend shows fine
  legend("topright",
         inset=0.02,
         legend=c("vote yes", "vote no"),
         lty=c("solid","dashed"),
         col=c("blue","red"))
}

# server code
  observe({
    output$plot <- renderPlot({
      myFunction()
    })
  })

我得到了一个带有图例的情节。但是这些线没有显示出来。我已经在Shiny以外尝试过了,一切都显示正常。

0 个答案:

没有答案