简体   繁体   English

R闪亮的情节大小

[英]R shiny plot size

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)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM