facet strip thickness?

1,625 views
Skip to first unread message

CK

unread,
Nov 5, 2011, 10:56:06 PM11/5/11
to ggplot2
Is there a way to specify the width/height of the panel strips in a
facet plot? I can see that changing the font size via opts changes it
automatically, e.g.

+opts(strip.text.y = theme_text(size=6, face='bold'))

However I would like a much thinner strip with minimal padding. Is
this possible?

Dennis Murphy

unread,
Nov 6, 2011, 12:57:43 AM11/6/11
to CK, ggplot2
https://github.com/hadley/ggplot2/wiki/Faceting-Attributes

is probably a good place to start.

Dennis

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> Please provide a reproducible example: http://gist.github.com/270442
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>

CK

unread,
Nov 6, 2011, 1:29:35 AM11/6/11
to ggplot2
Is the answer there? As far as I can tell:

panel.margin () -- space between the panels
strip.text.y (text) -- font of the panel strip text
strip.text.x (text) -- same
strip.background (rect) -- background of the panel strip

Also tried 'theme_get()' but don't see any obvious setting for panel
strip re-sizing.

Brandon Hurr

unread,
Nov 6, 2011, 2:46:13 AM11/6/11
to CK, ggplot2
I imagine that feature is automatically done based upon the size of the text and the "padding" is constant. Takahasi of Hadley would know for sure. 

Dennis Murphy

unread,
Nov 6, 2011, 11:16:42 AM11/6/11
to CK, ggplot2
I expected that theme_rect would allow you to control the height or
width of a strip, but it turns out to be hardcoded:

> theme_rect
function (fill = NA, colour = "black", size = 0.5, linetype = 1)
{
structure(function(x = 0.5, y = 0.5, width = 1, height = 1,
...) {
rectGrob(x, y, width, height, ..., gp = gpar(lwd = size *
.pt, col = colour, fill = fill, lty = linetype),
)
}, class = "theme", type = "box", call = match.call())
}
<environment: namespace:ggplot2>

(see the line starting with structure).

I tried to modify the function to accept a height argument, but
unsurprisingly, it didn't fly because the argument clashes with
previous code used to render the plot. You may have to try the grid
package to change strip heights, or wait to see if one of the
developers chimes in with a solution.

Sorry for the noise,
Dennis

Reply all
Reply to author
Forward
0 new messages