2017-08-10 16 views
0

私はShinyを使用してアプリケーションを作成していて、symbols()機能を使用して作成された温度計のプロットを含めたいと考えています。私は私の温度計プロットのための次のコードを書かれて、それがRStudioのプロットビューアで完全に正常に動作します:温度計のシンボルがShiny

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

しかし、私はシャイニーでこれを使用しようとすると、何もページに表示されません。ページを点検

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要素が作成されていることを示しているが、温度計がありません。ここに私のコードです。助言がありますか?プロットを作るために

答えて

1

あなたは出力サーバーサイドを作成し、UIでそれをレンダリングする必要がある、シャイニーに表示されます:

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) 

EDIT:かもしれないプロットの別の方法あなたのコメントに基づいて:

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) 

これにより、温度計の周りの軸とボックスが取り除かれ、わずかに見えるようになります。

+0

ありがとうございました。温度計の「ズームイン」をすると、周りに空白があまりありません。 –

+0

「ズームイン」という意味はよく分かりませんが、 'c(0.3,9,4.1/9)'の第2引数を変更することで体温計をより幅広く/狭くすることができます。私はあなたが元の質問の軸を削除したことに気付きました。あなたの 'symbols'コマンドに' yaxt = 'n'、xaxt = 'n'、bty = 'n' 'を加えることでそれを行うことができます。 – Eumenedies