I'd like to create two temperature curves in one plot. My Dataframe looks like this:
temp <- read.table(text = " Time Temp1 Temp2
1 00:00 18.62800 18.54458
2 00:10 18.60025 18.48283
3 00:20 18.57250 18.36767
4 00:30 18.54667 18.36950
5 00:40 18.51483 18.36550
6 00:50 18.48325 18.34783
7 01:00 18.45733 18.22625
8 01:10 18.43767 18.19067
9 01:20 18.41583 18.22042
10 01:30 18.39608 18.21225
11 01:40 18.37625 18.18658
12 01:50 18.35633 18.05942
13 02:00 18.33258 18.04142", header = T)
How can I get clean curves (no edges on the lines like a linechart) by only showing each hour (24 hours) on the x-axis? Im thinking about something with ggplot2 but I'm still learning R basics.
If you want to plot all values but only have full hours as x-axis labels you can plot the data with the
ggplot
package and use thescale_x_discrete()
option to specify thebreaks
.http://ggplot2.tidyverse.org/reference/scale_discrete.html
We can use the
tidyverse
for this. First we "clean" the data from all unnecessary rows by only taking time values with00
minutes and then we use aggplot
to visualize the temperatures.Temp2
can be added to the plot withyou can also use
lubridate
to subset the Time column: