I have a plot that I show in a box and I want to modify the size of the box, but the plot is bigger than the box.How can I modify both of them, so that the plot remains and fits the box?
#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"))
})
You can modify a size of the plot. So that it would fit in the box. You can do like this to modify a plot size:
## 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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.