使用两个不同的设置标签创建构面网格

时间:2017-06-09 19:26:42

标签: r ggplot2

我希望创建一个具有两个不同设置标签的构面网格。 下面是我创建的图表:

My graph

我想将y轴刻度更改为从顶部网格的1到5以及底部网格的-3到+3。

这是我目前的代码:

# make graph
ggplot(data = S2, mapping = aes(y = Rating, x = week, group= Question, colour= Question))+ 
  geom_point()+
  geom_line()+
  scale_colour_manual(values=c(mycols))+
  facet_grid(measureType ~., scales= "free")+
  geom_smooth(method = 'loess', colour= "black", aes(group=1), se= FALSE)+
  theme(legend.position="bottom",
        axis.text = element_text(family= "sans", face= "bold", colour = "black"),
        axis.title.x = element_text(family= "sans", face= "bold", colour = "black"),
        axis.title.y = element_text(family= "sans", face= "bold", colour = "black"),
        strip.text.x = element_text(family= "sans", face= "bold", colour = "black"),
        strip.text.y = element_text(family= "sans", face= "bold", colour = "black"),
        strip.background = element_rect(colour="#9C964A", fill="#FAD77B"),
        panel.border = element_rect(color = "#9C964A", fill = NA, size = 1), 
        axis.line = element_line(colour = "#9C964A", size=1)) +
  labs (x= "Date", y="Ratings by Question: 838607")

提前谢谢!!

*****编辑****** 这不是另一个问题的重复,因为我不希望我的秤“自由”。我希望它们明确地设置为1到5和+3到-3。我遇到的问题是如何让它们与众不同但又有所不同。

请查看我的附件数据。

> dput (S2) structure(list(StudentFactor = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = "838607", class = "factor"), Question = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 8L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L), .Label = c("Q", "Q10", "Q11_1", "Q11_2", "Q11_3", "Q11_4", "Q11_5", "Q12", "Q2", "Q8"), class = "factor"), Type = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("FYS", "SNR"), class = "factor"), measureType = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("Rating", "Delta"), class = "factor"), week = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 11L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 11L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 11L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 11L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 11L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L), .Label = c("Jan11", "Jan25", "Feb1", "Feb8", "Feb15", "Mar1", "Mar8", "Mar15", "Mar22", "Mar29", "Apr5"), class = "factor"), Rating = c(5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, -1, 5, 5, 5, 5, 5, 4, 4, 5, 4, 3, 0, 0, 0, 0, 0, -1, 0, 1, -1, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, -1, 0, 0, 5, 5, 5, 5, 5, 4, 4, 4, 3, 4, 0, 0, 0, 0, 0, -1, 0, 0, -1, 5, 5, 5, 5, 5, 4, 4, 4, 4, 3, 0, 0, 0, 0, 0, -1, 0, 0, 0)), class = "data.frame", row.names = c(NA, -95L), .Names = c("StudentFactor", "Question", "Type", "measureType", "week", "Rating"))

0 个答案:

没有答案