1

Description:

Here is a screenshot of my dashboard that I created with the shiny-package in R. It simply contains a static multiplot (via ggplot and grid.arrange).

Shiny Dashboard with unwanted white areas.

Problem:

There are white areas in the figure which I want to be grey. Just as the background. I have to use grid.arrange to produce the figure.

Question:

How do I need to change the code to make the white areas grey? The code is attached below.

library(shiny)
library(grid)
library(gridExtra)
library(plyr)
library(dplyr)
library(tidyr)
library(ggplot2)
library(DT)
library(shinydashboard)
library(bubbles)
require(igraph)
require(rCharts)
library(formattable)
library(networkD3)
library(shinyjs)
data(MisLinks)
data(MisNodes)




ui=dashboardPage(
  #skin = "black",

  dashboardHeader(title =  "MyTitle"),

  dashboardSidebar(
   "nothing here"



  ),


  # Show a plot of the generated distribution
 dashboardBody(

                  plotOutput("meinPiePlot")

                  )
)




server=function(input,output,session){



   output$meinPiePlot=renderPlot({



   Plot01=ggplot(NULL, aes(x="", y=mtcars$qsec, fill=mtcars$disp))+
   geom_bar(width = 1, stat = "identity")+
    coord_polar("y", start=0.8)+
    theme(plot.background = element_rect(fill = "#ECF0F5",
                               colour = "#ECF0F5",
                                linetype = "solid"),

            strip.background= element_rect(fill = "green",
                                colour = "green",
                                size = 0.5, linetype = "solid"),                    


            panel.background=element_rect(fill = "#ECF0F5",
                               colour = "#ECF0F5"),
            #aspect.ratio = 1 / 1.4,
            axis.text.x=element_blank(),
            legend.position="none"
                                )

       Plot02=ggplot(NULL, aes(x="", y=mtcars$disp, fill=mtcars$mpg))+
   geom_bar(width = 1, stat = "identity")+
    coord_polar("y", start=0.8)+
    theme(plot.background = element_rect(fill = "#ECF0F5",
                               colour = "#ECF0F5",
                                linetype = "solid"),

            strip.background= element_rect(fill = "green",
                                colour = "green",
                                size = 0.5, linetype = "solid"),                    


            panel.background=element_rect(fill = "#ECF0F5",
                               colour = "#ECF0F5"),
            #aspect.ratio = 1 / 1.4,
            axis.text.x=element_blank(),
            legend.position="none"
                                )

    grid.arrange(Plot01,Plot02, ncol=2)



    })



}

shinyApp(ui, server)
nexonvantec
  • 572
  • 1
  • 5
  • 18
  • 1
    It would make it much easier to help you if you minimized your example. Many of the packages that you are loading are clearly not necessary (for example). – CJ Yetman Mar 08 '18 at 19:47

1 Answers1

2

You could try the ggdraw() function from the cowplot package as also showed here:

g <- grid.arrange(Plot01, Plot02, ncol = 2)
cowplot::ggdraw(g) + 
  theme(plot.background = element_rect(fill="#ECF0F5", color = NA))

enter image description here

Valentin_Ștefan
  • 6,130
  • 2
  • 45
  • 68