将facet_wrap打印到PDF上的多个页面

时间:2018-04-16 17:54:54

标签: r ggplot2 facet-wrap

我有一组使用facet_wrap

生成的15-20个图
P <- Data_Backs %>% 
ggplot(aes(x=Period, y=M_Min, colour = Day_Week)) + 
geom_point(alpha = .3, size = 2)+
geom_line(aes(group=`Day Name`)) +
geom_hline(yintercept = 120, show.legend = T)+
facet_grid(facets =  Position~Player.Name) + 
geom_smooth()+
theme(plot.title = element_text(size=.1)) 

我需要能够打印出地块,但这会以非常狭窄的方式产生它们。理想情况下,每A4页需要6个绘图(每页2x3网格)我尝试使用这里的答案:Segment facet_wrap into multi-page PDF但是无法根据我的情况更改脚本?

这可能吗? 感谢

编辑:添加数据

Data_Backs = structure(list(Season = c(1718, 1718, 1718, 1718, 1718, 1718, 
1718, 1718, 1718, 1718), Week = c("Wk 40 Newcastle_H", "Wk 40 Newcastle_H", 
"Wk 40 Newcastle_H", "Wk 40 Newcastle_H", "Wk 40 Newcastle_H", 
"Wk 40 Newcastle_H", "Wk 40 Newcastle_H", "Wk 40 Newcastle_H", 
"Wk 40 Newcastle_H", "Wk 40 Newcastle_H"), Day_Week = c("Wk 40 Newcastle_H 
A_League_Newcaslte", 
"Wk 40 Newcastle_H A_League_Newcaslte", "Wk 40 Newcastle_H 
A_League_Newcaslte", 
"Wk 40 Newcastle_H A_League_Newcaslte", "Wk 40 Newcastle_H 
A_League_Newcaslte", 
"Wk 40 Newcastle_H A_League_Newcaslte", "Wk 40 Newcastle_H 
A_League_Newcaslte", 
"Wk 40 Newcastle_H A_League_Newcaslte", "Wk 40 Newcastle_H 
A_League_Newcaslte", 
"Wk 40 Newcastle_H A_League_Newcaslte"), Date = structure(c(1522627200, 
1522627200, 1522627200, 1522627200, 1522627200, 1522627200, 1522627200, 
1522627200, 1522627200, 1522627200), class = c("POSIXct", "POSIXt"
), tzone = "UTC"), Day = c("Mon", "Mon", "Mon", "Mon", "Mon", 
"Mon", "Mon", "Mon", "Mon", "Mon"), `Training/Match` = c("Match_A", 
"Match_A", "Match_A", "Match_A", "Match_A", "Match_A", "Match_A", 
"Match_A", "Match_A", "Match_A"), `Day Name` = c("A_League_Newcaslte", 
"A_League_Newcaslte", "A_League_Newcaslte", "A_League_Newcaslte", 
"A_League_Newcaslte", "A_League_Newcaslte", "A_League_Newcaslte", 
"A_League_Newcaslte", "A_League_Newcaslte", "A_League_Newcaslte"
), `Full Match/Training/Quarters` = c("Q_1", "Q_1", "Q_1", "Q_1", 
"Q_1", "Q_1", "Q_1", "Q_2", "Q_2", "Q_2"), `Squad Classification` = 
c("Academy", 
"Senior", "Senior", "Academy", "Academy", "Senior", "Academy", 
"Academy", "Senior", "Senior"), `Forward/Back` = c("Backs", "Backs", 
"Backs", "Backs", "Backs", "Backs", "Backs", "Backs", "Backs", 
"Backs"), Position = structure(c(8L, 6L, 5L, 8L, 7L, 8L, 7L, 
8L, 6L, 5L), .Label = c("Prop", "Hooker", "Second Row", "Back Row", 
"Scrum Half", "Fly Half", "Centre", "Wing/FullBack"), class = "factor"), 
Player.Name = c("Hearle Alex", "Jones Dorian", "Hart Grayson", 
"David Nick", "Lawrence Ollie", "Howe Tom", "Butler Will", 
"Hearle Alex", "Jones Dorian", "Hart Grayson"), Period = structure(c(1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("Min_1", 
"Min_2", "Min_3", "Min_4", "Min_5", "Min_6", "Min_7", "Min_8", 
"Min_9", "Min_10"), class = "factor"), M_Min = c(167.1708, 
147.061866666667, 153.61675, 169.90125, 141.748647746244, 
133.883, 162.0338, 121.41225, 158.517633333333, 167.148414023372
)), .Names = c("Season", "Week", "Day_Week", "Date", "Day", 
"Training/Match", "Day Name", "Full Match/Training/Quarters", 
"Squad Classification", "Forward/Back", "Position", "Player.Name", 
"Period", "M_Min"), row.names = c(NA, -10L), class = c("tbl_df", 
"tbl", "data.frame"))

0 个答案:

没有答案