I am facing a problem when adding transparency to the ggplot2
plots. I am losing resolution of the tickmark and axis labels. Below is what is happening :
I have imported "cyborg" bootstrap theme from here. Hence I believe the problem arise due to this them color not matching with the plot bg.
Code :
# to exhibit low resolution plots
# Global variables can go here
library(shiny)
waterfall_data <- data.frame(
id = 1:6,
factors = letters[1:6],
values = c(1:6)
)
waterfall_data$factors <- factor(waterfall_data$factors, levels = letters[1:6])
waterfall_data$end <- cumsum(waterfall_data$values)
waterfall_data$start <- c(0, head(waterfall_data$end, -1))
waterfall_data$end <- c(head(waterfall_data$end, -1), 0)
# Define the UI
ui <- fluidPage(theme = "bootstrap_cyborg.css",
sidebarLayout(
sidebarPanel(
),
mainPanel(
plotOutput('plot')
)
)
)
# Define the server code
server <- function(input, output) {
output$plot <- renderPlot({
plot <- ggplot(waterfall_data, aes(factors)) +
geom_rect(aes(x = factors, ymin = end, ymax = start, xmin = id-0.45, xmax = id+0.45 ),
fill = 'darkgreen')+
xlab(label = "columns")+
ylab(label = "value")+
geom_text(aes(label = values, y = end),vjust=-0.5)+
theme(
panel.background = element_rect(fill = "transparent") # bg of the panel
, plot.background = element_rect(fill = "transparent") # bg of the plot
, panel.grid.major = element_blank() # get rid of major grid
, panel.grid.minor = element_blank() # get rid of minor grid
, legend.background = element_rect(fill = "transparent") # get rid of legend bg
, legend.box.background = element_rect(fill = "transparent") # get rid of legend panel bg
)
print(plot)
}, bg="transparent")
}
# Return a Shiny app object
shinyApp(ui = ui, server = server)
Is there a way to use this theme and also have plot labels clear?