Combine facet_grid stucture with facet_wrap axis

Viewed 124

I have Data similar to this Example (with a larger value range).

Day <- rep(1:5, times=6) 
Fruit <- rep(c("Apple", "Banana", "Blueberry"), times = c(15,10,5)) 
Colour <- rep( c("Yellow","Red", "Green", "Yellow","Blue", "Purple"), each=5)
Values <-rep(c(3,4,5,6,7,4,5,6,7,8,5,6,7,8,9), times=2) 
SorS <- rep("Sweet", times=30) 
sweet <-data.frame(Day, Fruit, Colour, Values, SorS) 
SorS <- rep("Sour", times = 30) 
sour <- data.frame(Day, Fruit, Colour, Values, SorS) 
sour$Values <- sour$Values*10 
sour$Day <- sour$Day*10 
Data <- rbind(sweet, sour)

It would be nice to have single axis for each facet, as present using facet_wrap

ForPlot <-  ggplot(Data, aes(Day, Values), fill=Colour)

    ForPlot+
      geom_point(aes(fill=Colour))+
      ggtitle("Fruity Colours")+
      ylab("Values") + xlab("Day") +
      facet_wrap(SorS~Fruit,  scales= "free", ncol=3)

enter image description here

To simplify the understanding of what is displayed (and compared), it would be great to combine these diagrams(separate axis) with the table like labelling structure of facet_grid:

ForPlot <-  ggplot(Data, aes(Day, Values), fill=Colour)

ForPlot+
  geom_point(aes(fill=Colour))+
  ggtitle("Fruity Colours")+
  ylab("Values") + xlab("Day") +
  facet_rep_grid(SorS~Fruit,  scales= "free", switch="y")

enter image description here

I hope my problem is understandable. Thanks for your help :)

0 Answers
Related