2017-10-23 31 views
0

私はボックスに表示するプロットを持っていますが、ボックスのサイズを変更したいのですが、プロットはボックスよりも大きくなります。プロットが残るように、ボックスに合う?R光沢のあるプロットのサイズ

#in ui.r 
box(
        title = "Veniturile si cheltuielile", 
        status = "primary", 
        solidHeader = TRUE, 
        collapsible = TRUE, 
        plotOutput("ven_vs_chelt") 
       ) 




#in server.r 
output$ven_vs_chelt <- renderPlot({ 
    ggplot(ven_ch, aes(x=ven_ch$ani_tot, y=ven_chelt, fill=tip)) + 
     geom_bar(stat="identity", position=position_dodge(), colour="black") + 
     xlab("An") + ylab("Valoare venituri si cheltuieli(lei)") + 
     scale_fill_manual(values=c("#F78181", "#81F79F")) 
    }) 
+0

いくつかのヒント:あなたは、プロットのサイズを変更するには、このように行うことができます1)あなたは、あなたのコードが再現するべき応答を取得するには、https://stackoverflow.com/questions/5963269/how-to-を参照してくださいmake-a-great-r-reproducible-exampleを使用します。 2)より一般的なのは、動的UI要素を探していることです。したがって、 'renderUI()'を見てください。さらに質問がある場合は、1)を参考にしてください。 – BigDataScientist

答えて

0

プロットのサイズを変更できます。それがボックスに収まるように。

## In your ui, set the width to 100% in your plotOutput 
plotOutput(outputId = "ven_vs_chelt", width = "100%") 

## In your server, you specify height and width to make a plot fit in your box. You should play with height and width. So that it would fit in the box. 
output$ven_vs_chelt <- renderPlot({ 
ggplot(ven_ch, aes(x=ven_ch$ani_tot, y=ven_chelt, fill=tip)) + 
    geom_bar(stat="identity", position=position_dodge(), colour="black") + 
    xlab("An") + ylab("Valoare venituri si cheltuieli(lei)") + 
    scale_fill_manual(values=c("#F78181", "#81F79F")) 
}, height = 300, width = 450) 
+0

応答するには、ウィンドウサイズを取得する必要があります。私は、あなたがこのプロットをより反応的にするためにこの質問に進むべきだと思います:[Responsive Plot](https://stackoverflow.com/questions/44324783/dynamically-adjust-height-and-or-width-of-shiny-plotly-output -based-on-window-si)である。 – Santosh

関連する問題