Areza
Areza

Reputation: 6080

Size and space between subplots in ggplot2

I have a subplot as following

mydata <- data.frame(side1=rep(LETTERS[1:3],3,each=9),side2=rep(LETTERS[1:3],9,each=3),widget=rep(c("X","Y","Z"),9*3),size=rep(1/3,9*3),strength=runif(27,-1,1))

ggplot(mydata, aes(x="",y = size, fill = strength, width = widget)) +
geom_bar(width = 1) + 
facet_grid(side1 ~ side2) +
scale_x_discrete("",breaks=NULL) + 
coord_polar("y") + scale_fill_gradient2() +
scale_y_continuous("",breaks=NULL)+
theme(panel.grid=element_blank(),panel.border=element_blank())

I would like reduce the space between each subplot as well as their size. since I am after making 100x100 subplot. So being close to each other and also the size is really important.

Upvotes: 0

Views: 2034

Answers (1)

Didzis Elferts
Didzis Elferts

Reputation: 98589

To reduce the space between subplots use panel.margin= in theme(), for example

library(grid)    
+theme(panel.margin=unit(0,"cm"))

To set unit() you should use library grid.

The size of each subplot will depend on size of tho whole plot. You can set the size of whole plot using ggsave() function to save plot in some of formats (pdf, jpg) and setting width= and height= of whole plot.

Upvotes: 4

Related Questions