The main header in grid.arrange or organizGrob has a gray background

I am moving from ggplot2 1.0.1 and gridExtra 0.9.1 to the latest versions of these packages and am struggling with some minor issues at the moment.

One problem is the heading in the combo chart.

 library(ggplot2) library(gridExtra) df <- data.frame(x=runif(100), y=runif(100)) p1 <- ggplot(df, aes(x,y)) + geom_point() p2 <- ggplot(df, aes(x,y)) + geom_point() a <- arrangeGrob(p1,p1,p2, layout_matrix=rbind(c(1,2),c(1,3)), top='my title') plot(a) ggsave('a.pdf', a) 

in the old version, the parameter was called main , and I had to use print to plot a . Now, when I save the schedule, everything is in order. But plot(a) graph has a light gray grid background for my title . In the saved pdf file, the background is white again.

I also tried using grid.arrange , but I don't want to print the plot directly at runtime. This is why I use a two-step approach by storing the graph in a variable and then plot it.

So, how do I get a white background when plot(a) ?

+5
source share
1 answer

Use grid.draw . The plot method is for testing only.

 library(grid) grid.newpage() grid.draw(a) 

final schedule

+4
source

Source: https://habr.com/ru/post/1239799/


All Articles