I am trying to compile 35 graphs together, and sort them based on the columns "size" and "behavior". Individually, the graphs are composed of movement data over time. I would like my size categories to sort vertically and the behavior to sort horizontally.
I can compile the 35 graphs together with the following code:
g<-ggplot(data,aes(x=time,y=distance))+
geom_point(aes(color=Location))+
scale_x_datetime(name="Date", date_breaks="1 months",labels=date_format(format="%b-%Y")) +
theme(axis.text.x=element_text(angle = 90,size=5, hjust = 0))+
ggtitle("All Plots")+
theme(plot.title = element_text(hjust = 0.5)) +
ylab("distance") +
facet_wrap( ~ individual,labeller = label_parsed)
I would like these graphs to be sorted vertically by size class, and horizontally as behavior.
I have tried to include size and behavior in facet_wrap like so:
g + facet_wrap(size ~ individual + behavior, label = label_wrap_gen(multi_line=FALSE))
But this only pastes the size and behavior under individual on each graph.
I have also tried facet_grid:
g + facet_grid(data$size, data$behavior)
And get the following error: rows
must be NULL
or a vars()
list if cols
is a vars()
list.
Am I going about this in the wrong way? Any help is much appreciated!