首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >温度计符号(闪亮)

温度计符号(闪亮)
EN

Stack Overflow用户
提问于 2017-08-10 21:56:44
回答 1查看 376关注 0票数 0

我正在创建一个使用Shiny的应用程序,并希望包括一个温度计绘图,使用symbols()函数创建。我为我的温度计绘图编写了以下代码,它在RStudio的绘图查看器中工作得很好:

symbols(0, thermometers = cbind(0.3, 9, 4.1/9), fg = 2, xlab = NA, ylab = NA, inches = 2.5, axes = F)

但是,当我尝试在Shiny中使用它时,页面上什么也没有显示。下面是我的代码:

server = function(input, output, session) { ... (not needed for this plot) } ui = fluidPage( tags$div(id="thermometer", style = "height:600px;", symbols(0, thermometers = cbind(0.3, 9, 4.1/9), fg = 2, xlab = NA, ylab = NA, inches = 2.5, axes = F)) ) shinyApp(ui = ui, server = server)

检查页面显示正在创建div,但温度计不在那里。有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-10 22:20:36

为了使绘图显示在Shiny中,您需要创建一个输出服务器端,然后在ui中呈现它:

代码语言:javascript
复制
server = function(input, output, session) {
  #... (not needed for this plot)
  output$thermometer <- renderPlot({
    symbols(0, thermometers = cbind(0.3, 9, 4.1/9), fg = 2, xlab = NA, ylab = NA, inches = 2.5)
  })
}
ui = fluidPage(
  tags$div(id="thermometer", style = "height:600px;", plotOutput("thermometer"))
)
shinyApp(ui = ui, server = server)

编辑:根据您的注释,另一种绘图方法可能是:

代码语言:javascript
复制
library(shiny)

server = function(input, output, session) {
  #... (not needed for this plot)
  output$thermometer <- renderPlot({
    symbols(0, thermometers = cbind(0.3, 1, 4.1/9), fg = 2, xlab = NA, ylab = NA, inches = 2.5, yaxt='n', xaxt='n', bty='n')
  })
}
ui = fluidPage(
  tags$div(id="thermometer", style = "height:600px;width:200px;margin:auto", plotOutput("thermometer"))
)
shinyApp(ui = ui, server = server)

这将移除温度计周围的轴和方框,并使其更容易看到。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45615819

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档