R Shiny改变图的高度

时间:2017-06-26 10:07:50

标签: r plot shiny

我正在尝试设置绘图的高度,但似乎无法在绘图函数中获取高度参数来实际执行任何操作。有没有人有任何建议?

  output$probability_chart <- renderPlot({
    xvals <- 1:17 
    req(input$countrySelectProbabilities)
    idx <- which(input$countrySelectProbabilities==FVI_DATA_ALL_COUNTRIES)

    max_comp_prob <- max(Composite_Probabilities_1_DF[idx, 2:18], na.rm=TRUE)
    max_bank_prob <- max(Banking_Probabilities_1_DF[idx, 2:18], na.rm=TRUE)
    max_curr_prob <- max(Currency_Probabilities_1_DF[idx, 2:18], na.rm=TRUE)
    max_sove_prob <- max(Sovereign_Probabilities_1_DF[idx, 2:18], na.rm=TRUE)
    max_sudd_prob <- max(Sudden_Stop_Probabilities_1_DF[idx, 2:18], na.rm=TRUE)

    overall_max_prob <- max(max_comp_prob, max_bank_prob, max_curr_prob, max_sove_prob, max_sudd_prob, na.rm=TRUE)


    plot(x = xvals, y=Composite_Probabilities_1_DF[idx, 2:18], type = "l"
         , xlab = "", ylab = "", col="grey20", ylim = c(-10, overall_max_prob), lwd=3, las=2)
    mtext("Financial Vulnerability Indicator", side=3, adj=0, line=1.2, cex=2, font=2)
    mtext("Probability", side=3, adj=0, line=0.1, cex=1, font=0.5)
    axis(1,at=xvals,label=dates, cex.axis=1, las=2)
    lines(xvals, Banking_Probabilities_1_DF[idx, 2:18], col="green2", lwd=3)
    lines(xvals, Currency_Probabilities_1_DF[idx, 2:18], col="purple", lwd=3)
    lines(xvals, Sovereign_Probabilities_1_DF[idx, 2:18], col="red", lwd=3)
    lines(xvals, Sudden_Stop_Probabilities_1_DF[idx, 2:18], col="orange", lwd=3)
    legend(
      "bottom", 
      lty=c(1,1,1,1), 
      lwd=c(3,3,3,3), 
      col=c("grey20", "green2", "purple", "red", "orange"), 
      legend = c("Composite", "Banking", "Currency", "Sovereign", "Sudden Stop")
      ,ncol=5
    )
  })

1 个答案:

答案 0 :(得分:3)

server.R中您应该在plotOutput旁边添加高度参数:

 plotOutput("plot", height=800)