# How to specify labels per facet in ggplot2? [closed]

I am using ggplot and I would like to label the scales in each facet of a plot manually. The concept is discussed here:

The solutions provided there work but I am still wondering if ggplot yet supports the option to provide scale labels per facet.

Thanks,

• This probably belongs on stackoverflow – Andrie Aug 10 '11 at 22:00
• @Andrie Please read our FAQ to see what this site covers. Questions about data visualization are welcomed. Perhaps we need a meta discussion, because the community has frequently been suggesting migrations for pedestrian "how-to" questions like this one. – whuber Aug 10 '11 at 22:16
• Fair enough.... – Andrie Aug 10 '11 at 22:20
• To add different y labels, refers to stackoverflow.com/a/37574221/5996475. – Liang Zhang Apr 29 at 13:15

The answer is no. However, as you saw in the link you posted, there is grid.arrange::gridExtra. Another option is to use something that's originally from the ggplot2 book (I think that's the source, but examples abound on the internet)

p1 <- ggplot(diamonds, aes(depth, carat)) + geom_point()
p2 <- ggplot(diamonds, aes(price, carat)) + geom_point()
vplayout <- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y)
grid.newpage()
pushViewport(viewport(layout=grid.layout(4,6)))
print(p1,vp=vplayout(1:4,1:3))
print(p2,vp=vplayout(1:4,4:6))


This setup essentially plots a "dashboard". And you can control each plot individually, yet, keep them "beside eachother in any arrangement that you feel reasonable by changing the squares they fill (mess with the numbers 4, 6, 1:4, 1:3, 4:6)

• I'm glad you answered this, giving me the opportunity to add that faceting has a specific purpose that is designed around identical axes. The more you want each panel to be designed differently, the more you need a tool that just isn't faceting, and is more like grid.arrange or using grid.layout directly as you mention. – joran Aug 11 '11 at 4:09
• Thanks for the answer Brandon, I ended up using grid.arrange but I did also see the viewport stuff at the end of the ggplot book. Joran I concur with your answer as well. – z0lo Aug 12 '11 at 15:30

You can use labeller option to specify labels for each facet. See this link Question