How to change the strips caption

5 views
Skip to first unread message

Felipe

unread,
Jul 1, 2010, 1:29:11 PM7/1/10
to ggplot2
Hi:
I am trying to change the strips caption when using
facet_grid or facet_wrap:
Based on the example below, how the strips caption
can be changed to something else eg. 1,2,3,4,5
I was reading about 'labeller' inside facet_grid but couldn't
find any clear examples about it's use.

# faceting displays subsets of the data in different panels
p <- ggplot(diamonds, aes(carat, ..density..)) +
geom_histogram(binwidth = 0.2)

# With one variable
p + facet_grid(. ~ cut)

Hadley Wickham

unread,
Jul 3, 2010, 8:42:04 AM7/3/10
to Felipe, ggplot2
Hi Felipe,

The easiest way is to create a new variable that has the labels you want:

diamonds$cut_label <- as.numeric(diamonds$cut)
p + facet_grid(. ~ cut_label)

Hadley

> --
> 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
>

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages