I want to plot the data below as a single plot in ggplot2. time_s on x-axis, dS2_mV and oS2_mV on the primary y-axis and dS2_mr_cs oS2_mr_cs on the secondary y-axis. Any help will be appreciated. Thanks
time_s dS2_mV oS2_mV dS2_mr_cs oS2_mr_cs
1 0 211. 421. 1.08 -12.7
2 0.5 211. 421. 2.16 -25.4
3 1 212. 421. 3.47 -37.9
4 1.5 211. 421. 4.55 -50.7
5 2 212. 421. 5.86 -63.6
6 2.5 212. 421. 7.39 -76.5
7 3 212. 421. 8.70 -89.5
8 3.5 212. 421. 10.2 -102.
9 4 212. 421. 12.0 -115.
10 4.5 212. 421. 13.8 -127.
Hi, here is a reproducible version of your data.
df <- tibble::tribble(
~time_s, ~dS2_mV, ~oS2_mV, ~dS2_mr_cs, ~oS2_mr_cs,
0, 211L, 421L, 1.08, -12.7,
0.5, 211L, 421L, 2.16, -25.4,
1, 212L, 421L, 3.47, -37.9,
1.5, 211L, 421L, 4.55, -50.7,
2, 212L, 421L, 5.86, -63.6,
2.5, 212L, 421L, 7.39, -76.5,
3, 212L, 421L, 8.7, -89.5,
3.5, 212L, 421L, 10.2, -102,
4, 212L, 421L, 12, -115,
4.5, 212L, 421L, 13.8, -127
)
Here are some examples, though whether secondary axes are a good thing is up to you:
Creating A Dual-Axis Plot using R and ggplot (finchstudio.io)
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.
If you have a query related to it or one of the replies, start a new topic and refer back with a link.