[R-br] ggplot2 renomear strip elementos

Benilton Carvalho beniltoncarvalho em gmail.com
Quarta Outubro 3 11:05:10 BRT 2012


Crie um wrapper para os novos labels e use-o como argumento de 'labeller'.

list.paramiter <- read.csv("list_paramiter.csv", sep = ";")
library(ggplot2)
mywrapper <- function(variable, value){
    tmp <- as.character(value)
    tmp[tmp=='LVAd'] <- 'YRL'
    tmp[tmp=='LVdf'] <- 'DRL'
    tmp[tmp=='PVAd'] <- 'YRA'
    tmp
}
graficos <- ggplot(list.paramiter) +
                   aes(x = variable,
                       y = mean) +
  facet_grid(.~ Solo, labeller=mywrapper) +
  geom_point() +
  geom_line(data = list.paramiter,
            aes(x=variable, y= mean, linetype=Sol), size = 1)+
  geom_errorbar(data = list.paramiter,
                aes(y=mean, ymin = mean - std.err, ymax=mean + std.err),
                    width=0.2, position="identity")+
                    labs(x = "Week",
                    y = label.y.cong)+
  scale_linetype_manual(name="Solutions", values = c(15, 4, 1),
  labels=c("AGUA" = "DW", "SOSU" = "SW", "SONP" = "IS"))+
  scale_x_continuous(breaks=c(1:10), labels = c("1", "2", "3", "4",
"5", "6", "7",  "8", "9",  "10"))
graficos



b

2012/10/3 Alisson Lucrecio <alissonluc em yahoo.com.br>:
>
> Olá pessoal da r-br,
> Eu usava as funções ggplotGrob, grid.ls e getGrob para extrair os elementos
> do grid e renomear-los da forma que queria, mas o pacote ggplot2 teve uma
> alteração. Alguém sabe como fazer as alterações do strip.elementes com o
> ggplot2? Quero trocar os nomes LVAd, LVdf e PVAd para YRL, DRL e YRA,
> respectivamente. O link do arquivo segue abaixo:
>
> http://dl.dropbox.com/u/102629803/r%20br%20ajudar.rar
>
> Obrigado.
>
> Alisson Lucrécio da Costa
>
> _______________________________________________
> R-br mailing list
> R-br em listas.c3sl.ufpr.br
> https://listas.inf.ufpr.br/cgi-bin/mailman/listinfo/r-br
> Leia o guia de postagem (http://www.leg.ufpr.br/r-br-guia) e forneça código
> mínimo reproduzível.


Mais detalhes sobre a lista de discussão R-br