Jared
Jared

Reputation: 111

Plotting temporal data over multiple months using a standardized x-axis

Date_Time           Temp...C.   Anglers.Names           Water.Body
7/17/2016 8:05:00   24          Jones & Bishop          Lake 1
7/17/2016 9:05:00   25          Jones & Bishop          Lake 1
7/17/2016 10:05:00  26          Jones & Bishop          Lake 1
8/15/2016 8:00:00   26          Smith & Nelson          Lake 2
8/15/2016 9:00:00   26          Smith & Nelson          Lake 2
8/15/2016 10:00:00  27          Smith & Nelson          Lake 2
9/12/2016 8:02:00   25          Militello & Culberson   Lake 3
9/12/2016 11:02:00  26          Militello & Culberson   Lake 3
9/12/2016 14:02:00  26          Militello & Culberson   Lake 3

I have a dataset from a bass live well study where I monitored temperatures in angler's live wells by placing a temp logger in their live wells throughout a tournament day. My question is, is there a way to plot the temperature over time, faceted by the water body and then color coded by the unique angler's name. I'm not sure if the quickest way is to subset out by water body (I have 14 water bodies that I worked), creating 14 new individual datasets, make a plot for that individual water body, and then once I'm done arrange them using something like grid.arrange. When trying to make a single faceted plot for all water bodies, the problem I'm trying to work around is getting the x-axis limits to just be a standard range of hours, regardless of date (for me on my real data probably something like 7 AM - 3 PM since that's about how long most tournaments lasted). But since the study occurred over multiple months, R wants to use the entire 3 months as the x-axis limits.

LivewellTemp <- ggplot(HOBO.Data, aes(Date_Time, Temp...C.,colour=Anglers.Names))+
facet_wrap(~Water.Body)+
geom_line(linetype=2)

enter image description here

Upvotes: 0

Views: 421

Answers (1)

J.Con
J.Con

Reputation: 4307

Is this what you're after?

LivewellTemp <- ggplot(HOBO.Data, aes(Date_Time, Temp...C.,colour=Anglers.Names))+ facet_wrap(~Water.Body)+geom_line(linetype=2)+ scale_x_discrete(labels=c("7am", "8am", "9am", "10am", "11am", "12pm", "1pm", "2pm", "3pm"))

Upvotes: 1

Related Questions