Hi community
Im want to replicate this plot but I don`t know how add an extra y.axis in this form.
Some guide?
data_example <- structure(list(Date = structure(c(19297, 19298, 19299, 19300,
19301, 19302, 19303, 19304, 19305, 19306, 19307, 19308, 19309,
19310, 19311, 19312, 19313, 19314, 19315, 19316, 19317, 19318,
19319, 19320, 19321, 19322, 19323, 19324, 19325, 19326), class = "Date"),
P = c(2.7, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.2, 6.4,
6.4, 6.4, 6.4, 23.8, 29.7, 30.3, 30.3, 30.4, 31.4, 32.3,
32.3, 32.3, 32.3, 32.5, 35.2, 35.2, 35.2, 35.2, 35.2), D = c(0,
0, 0, 0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697,
0.0432551304342697, 0.0432551304342697, 0.0432551304342697
), dS = c(0, 0.144394894097204, 1.4002001319444, -0.235532354166693,
-3.2231233003472, -7.0622712586806, -11.0004165711806, -14.7897904704861,
-18.0646276173611, -20.6178504911458, -23.3009769368056,
-25.95491294375, -28.8935023295139, -31.9737702399306, -29.238169625,
-9.9785169409722, -5.70813761631949, -6.1108179027778, -7.06703965624999,
-8.9572423159722, -10.0701620104167, -11.5994326510417, -14.5294981684028,
-18.0743015833333, -20.8018105920139, -21.5491860451389,
-21.5080001232639, -22.7422270104167, -25.1658506142361,
-27.9260776472222), E = c(0, 3.3556051059028, 2.0997998680556,
3.69227722373242, 6.67986816991293, 10.5190161282463, 14.4571614407463,
18.2465353400518, 21.5213724869268, 24.0745953607115, 26.9577218063713,
29.6116578133157, 32.5502471990796, 35.6305151094963, 50.2949144945657,
36.9352618105379, 33.2648824858852, 33.6675627723435, 34.7237845258157,
37.6139871855379, 39.6269068799824, 41.1561775206074, 44.0862430379685,
47.631046452899, 50.5585554615796, 54.0059309147046, 53.9647449928296,
55.1989718799824, 57.6225954838018, 60.3828225167879)), row.names = c(NA,
30L), class = "data.frame")
data_example %>%
ggplot() +
geom_line(aes(x = Date, y = P, color = "P"), size = 1) +
geom_line(aes(x = Date, y = D, color = "D"), size = 1) +
geom_line(aes(x = Date, y = dS, color = "dS"), size = 1) +
geom_line(aes(x = Date, y = E, color = "E"), size = 1) +
scale_color_manual(values = c("P" = "red",
"D" = "green",
"dS" = "pink",
"E"='orange')) +
labs(color = "Variable") +
theme(legend.position = 'top')
My plot look like these:
Im find something like that: