anna
anna

Reputation: 195

ggplot2: change placement of facet titles

I have the same problem as in the question: Switch placement of facet_grid labels but using facet_wrap i can not get the scale_fill_manual to work.

I have coloured and set an order for my data using factor(data, levels =c()) and then: scale_fill_manual(values=c() and labels=c(), which works for facet_grid. Does anybody have a solution?

Upvotes: 1

Views: 281

Answers (2)

PereG
PereG

Reputation: 1846

Using the same data provided throught the link

library(plyr)
library(ggplot2)
data = data.frame(id = 1:10, value = rnorm(100*10))
data = ddply(data, .(id), transform, obs = 1:100)

fix the desired colors

myCol <- c(1:10)

and plot with scale_color_manual()

ggplot(data = data, aes(x = obs, y = value, color = factor(id))) + 
   geom_line() + facet_wrap( ~id, ncol=1) + scale_color_manual(values=myCol) 

enter image description here

Upvotes: 1

BjaRule
BjaRule

Reputation: 171

In the latest version of ggplot (released just a few days ago) they added a switch argument to facet_wrap, to allow us to switch labels from right to left or top to bottom. Perhaps that is what you are looking for. But it is very hard to say what the problem is with your color scales unless you post your code and output.

Upvotes: 1

Related Questions