I have a data frame called raw data that looks like this:
head(rawdata)
# A tibble: 6 x 9
Time Temp DO Pump1 GasFlo O2 pH Agit Pump3
<dttm> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 2023-08-08 22:00:00 37 134. 0 4.9 0 6.75 1200 0
2 2023-08-08 22:00:00 37 136. 0 4.9 0 6.75 1200 0
3 2023-08-08 22:01:00 37 132 0 4.9 0 6.75 1200 0
4 2023-08-08 22:01:00 37 134 0 4.9 0 6.75 1200 0
5 2023-08-08 22:02:00 37 134. 0 4.9 0 6.75 1200 0
6 2023-08-08 22:02:00 37 136. 0 4.9 0 6.75 1201 0
I want to plot Time in the X axis and the rest of the variables in the Y axis, and I would like to replace the "Series 1" "Series 2" ... "Series n" labels that appear automatically below the X axis with the actual name of the variables and their respective colors.
I want to plot all variables but to make the code simpler I only included three of them in this example. Here's what I have so far:
highchart() %>%
hc_chart(type = "line") %>%
hc_xAxis(categories = rawdata$Time) %>%
hc_yAxis_multiples(create_axis(naxis = 3),
list(title = list(text = "pH"),
lineWidth = 3,
showLastLabel = TRUE,
opposite = FALSE),
list(title = list(text = "DO"),
lineWidth = 3,
showLastLabel = TRUE,
opposite = FALSE),
list(title = list(text = "Base"),
lineWidth = 3,
showLastLabel = TRUE,
opposite = FALSE)) %>%
hc_add_series(rawdata$pH, yAxis = 0) %>%
hc_add_series(rawdata$DO, yAxis = 1) %>%
hc_add_series(rawdata$Pump1, yAxis = 2)
it turns out like this: This is the plot I get after running this code
I went over the highcharter package documentation but I just can't find how to replace those "Series" labels with the actual name of the variables. I haven't used R in years so please be nice :)