我有一个情节,我在一个盒子里显示,我想修改盒子的大小,但是情节大于盒子。如何修改它们,以便绘图保持并适合盒子?
#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 :(得分: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)