Mam szybkie pytanie dotyczące etykiet aspektów_wrap w ggplot2. Poniżej znajduje się prosta ramka danych. Jedna ze zmiennych (zmienna aspektowa) jest bardzo długa. Chcę znaleźć prosty sposób na dopasowanie całego tekstu do każdej etykiety aspektu. Jestem pewien, że musi istnieć jakaś funkcja zawijania tekstu lub opcja wielu linii? Mam nadzieję na metodę, która nie jest zbyt skomplikowana lub tak naprawdę nie wymaga żadnych innych pakietów, jeśli to możliwe. Nadal jestem względnie nowa z R i mając nadzieję na krótką i elegancką odpowiedź w ggplot2.Jak dopasować długi tekst do aspektu Ggplot2 Tytuły
Q1<-c("Dissatisfied","Satisfied","Satisfied","Satisfied","Dissatisfied","Dissatisfied","Satisfied","Satisfied")
Q2<-c("Dissatisfied","Dissatisfied","Satisfied","Dissatisfied","Dissatisfied","Satisfied","Satisfied","Satisfied")
Year<-c("This is a very long variable name This is a very","This is another really long veriable name a really long","THis is a shorter name","Short name","This is also a long variable name again","Short name","Short name","Another kind of long variable name")
Example<-data.frame(Service,Year,Q1,Q2)
ExampleM<-melt(Example,id.vars=c("Service","Year"))
ggplot(ExampleM, aes(x=variable, fill=value)) +
geom_bar(position="dodge")+
facet_grid(~Year)
Może pomocne: http://stackoverflow.com/questions/9052650/ggplot2-splitting-facet-strip-text-into-two -lines – lukeA
'? Ggplot2 :: label_wrap_gen' – hrbrmstr