6
$\begingroup$

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

http://groups.google.com/group/ggplot2/browse_thread/thread/d2044ed0f91de98a

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

Thanks,

$\endgroup$
4
  • 3
    $\begingroup$ This probably belongs on stackoverflow $\endgroup$
    – Andrie
    Aug 10, 2011 at 22:00
  • 1
    $\begingroup$ @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. $\endgroup$
    – whuber
    Aug 10, 2011 at 22:16
  • $\begingroup$ Fair enough.... $\endgroup$
    – Andrie
    Aug 10, 2011 at 22:20
  • $\begingroup$ To add different y labels, refers to stackoverflow.com/a/37574221/5996475. $\endgroup$ Apr 29, 2020 at 13:15

2 Answers 2

10
$\begingroup$

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)

$\endgroup$
2
  • 4
    $\begingroup$ 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. $\endgroup$
    – joran
    Aug 11, 2011 at 4:09
  • $\begingroup$ 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. $\endgroup$
    – z0lo
    Aug 12, 2011 at 15:30
1
$\begingroup$

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

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.