I am trying to plot 3-time series data (int1a, int1b, int2c) with fitted curves (xm1a, xm1b, xm1c) and trend lines (xm21a, xm21b, xm21c). I am getting the plot (see attachment), however, I am unable to put a legend on the top of this figure.
Code
fn_fr1 = data.frame(xs, int1a, xm1a, xm21a, int1b, xm1b, xm21b, int1c, xm1c, xm21c)
labs = c("2007","2008","2009","2010","2011","2012","2013","2014","2015","2016","2017")
ggplot(data=fn_fr1, aes(xs, y = value, color = variable)) +
theme_set(theme_bw()) +
# ------------------ NC --------------
geom_line(aes(y = xm1a), colour="black") +
geom_point(aes(y = int1a), shape =21, colour = "Black", fill="white") +
geom_line(aes(y = xm21a),colour='black', linetype="dashed", size=1.25) +
ylim(200,max(fn_fr1$int1a)) +
theme(plot.title=element_text(vjust=0.75, hjust=1.0)) +
scale_x_continuous(name="year", breaks=seq(0,10,1), labels=labs) +
ylab("CO (ppb)") +
# ------------------ YS --------------
geom_line(aes(y = xm1b), colour="Red") +
geom_point(aes(y = int1b), shape =25, colour = "Red", fill="white") +
geom_line(aes(y = xm21b),colour='Red', linetype="dashed", size=1.25) +
# ------------------ SK --------------
geom_line(aes(y = xm1c), colour="blue") +
geom_point(aes(y = int1c), shape =22, colour = "Blue", fill="white") +
geom_line(aes(y = xm21c),colour='blue', linetype="dashed", size=1.25) +
theme(legend.position = "top", legend.box = "horizontal") +
# scale_fill_identity(name = 'Fitting',values = c(int1a='point', xm1a='solid',xm21a='dashed'), labels = c('Data','Curve','Trend')) +
scale_colour_manual(name = 'Regions',values = c(int1a='black', int1a='red', int1c='blue'), labels = c('NC','YS','SK'))
Plot
Data
dput(fn_fr1) structure(list(xs = c(0.0833333333333333, 0.166666666666667, 0.25, 0.333333333333333, 0.416666666666667, 0.5, 0.583333333333333, 0.666666666666667, 0.75, 0.833333333333333, 0.916666666666667, 1, 1.08333333333333, 1.16666666666667, 1.25, 1.33333333333333, 1.41666666666667, 1.5, 1.58333333333333, 1.66666666666667, 1.75, 1.83333333333333, 1.91666666666667, 2, 2.08333333333333, 2.16666666666667, 2.25, 2.33333333333333, 2.41666666666667, 2.5, 2.58333333333333, 2.66666666666667, 2.75, 2.83333333333333, 2.91666666666667, 3, 3.08333333333333, 3.16666666666667, 3.25, 3.33333333333333, 3.41666666666667, 3.5, 3.58333333333333, 3.66666666666667, 3.75, 3.83333333333333, 3.91666666666667, 4, 4.08333333333333, 4.16666666666667, 4.25, 4.33333333333333, 4.41666666666667, 4.5, 4.58333333333333, 4.66666666666667, 4.75, 4.83333333333333, 4.91666666666667, 5, 5.08333333333333, 5.16666666666667, 5.25, 5.33333333333333, 5.41666666666667, 5.5, 5.58333333333333, 5.66666666666667, 5.75, 5.83333333333333, 5.91666666666667, 6, 6.08333333333333, 6.16666666666667, 6.25, 6.33333333333333, 6.41666666666667, 6.5, 6.58333333333333, 6.66666666666667, 6.75, 6.83333333333333, 6.91666666666667, 7, 7.08333333333333, 7.16666666666667, 7.25, 7.33333333333333, 7.41666666666667, 7.5, 7.58333333333333, 7.66666666666667, 7.75, 7.83333333333333, 7.91666666666667, 8, 8.08333333333333, 8.16666666666667, 8.25, 8.33333333333333, 8.41666666666667, 8.5, 8.58333333333333, 8.66666666666667, 8.75, 8.83333333333333, 8.91666666666667, 9, 9.08333333333333, 9.16666666666667, 9.25, 9.33333333333333, 9.41666666666667, 9.5, 9.58333333333333, 9.66666666666667, 9.75, 9.83333333333333, 9.91666666666667, 10), int1a = c(412.618, 417.365, 426.564, 436.479, 409.058, 420.529, 357.221, 337.316, 396.084, 328.479, 402.208, 403.981, 383.41, 419.888, 406.845, 418.03, 421.147, 403.514, 347.393, 309.471, 326.381, 304.262, 333.966, 381.643, 392.275, 366.146, 383.912, 386.86, 376.235, 378.791, 346.391, 337.8743, 329.3577, 320.841, 332.464, 394.367, 400.604, 449.253, 415.621, 428.912, 388.973, 415.633, 345.161, 335.088, 337.939, 310.362, 345.306, 385.682, 433.578, 363.128, 403.021, 387.169, 363.308, 369.108, 350.907, 309.599, 318.528, 315.991, 325.17, 393.396, 406.018, 434.134, 386.448, 379.065, 397.774, 406.794, 371.856, 342.974, 344.137, 334.502, 377.724, 399.812, 378.32, 391.701, 371.87, 387.259, 352.933, 341.107, 295.422, 329.295, 311.654, 321.219, 357.065, 366.415, 368.174, 334.571, 385.537, 381.445, 364.511, 365.879, 340.919, 353.402, 312.776, 313.294, 322.474, 385.18, 377.931, 423.021, 343.333, 367.12, 367.017, 347.578, 347.122, 363.955, 330.208, 306.996, 343.601, 389.57, 392.409, 406.115, 382.578, 380.56, 331.648, 339.755, 309.121, 280.077, 324.274, 290.452, 329.763, 383.197 ), xm1a = c(415.167934456542, 412.596130720935, 415.856825012261, 405.089519764465, 401.816536077282, 392.193298133505, 360.329956586584, 349.018817459014, 347.662836030865, 336.017798415484, 362.230854965844, 406.177420046444, 411.224017277482, 408.652213541875, 411.912907833201, 401.145602585406, 397.872618898222, 388.249380954445, 356.386039407524, 345.074900279955, 343.718918851805, 332.073881236424, 358.286937786784, 402.233502867384, 407.280100098422, 404.708296362815, 407.968990654142, 397.201685406346, 393.928701719162, 384.305463775386, 352.442122228464, 341.130983100895, 339.775001672745, 328.129964057364, 354.343020607725, 398.289585688324, 403.336182919363, 400.764379183756, 404.025073475082, 393.257768227286, 389.984784540103, 380.361546596326, 348.498205049404, 337.187065921835, 335.831084493685, 324.186046878304, 350.399103428665, 394.345668509265, 399.392265740303, 396.820462004696, 400.081156296022, 389.313851048226, 386.040867361043, 376.417629417266, 344.554287870345, 333.243148742775, 331.887167314626, 320.242129699245, 346.455186249605, 390.401751330205, 395.448348561243, 392.876544825636, 396.137239116962, 385.369933869167, 382.096950181983, 372.473712238207, 340.610370691285, 329.299231563716, 327.943250135566, 316.298212520185, 342.511269070546, 386.457834151145, 391.504431382184, 388.932627646576, 392.193321937903, 381.426016690107, 378.153033002924, 368.529795059147, 336.666453512225, 325.355314384656, 323.999332956506, 312.354295341125, 338.567351891486, 382.513916972085, 387.560514203124, 384.988710467517, 388.249404758843, 377.482099511047, 374.209115823864, 364.585877880087, 332.722536333166, 321.411397205596, 320.055415777447, 308.410378162066, 334.623434712426, 378.569999793026, 383.616597024064, 381.044793288457, 384.305487579783, 373.538182331988, 370.265198644804, 360.641960701027, 328.778619154106, 317.467480026537, 316.111498598387, 304.466460983006, 330.679517533366, 374.626082613966, 379.672679845004, 377.100876109397, 380.361570400724, 369.594265152928, 366.321281465744, 356.698043521968, 324.834701975046, 313.523562847477, 312.167581419327, 300.522543803946, 326.735600354306, 370.682165434906), xm21a = c(385.487456012838, 385.158796247916, 384.830136482994, 384.501476718073, 384.172816953151, 383.84415718823, 383.515497423308, 383.186837658386, 382.858177893465, 382.529518128543, 382.200858363621, 381.8721985987, 381.543538833778, 381.214879068856, 380.886219303935, 380.557559539013, 380.228899774091, 379.90024000917, 379.571580244248, 379.242920479326, 378.914260714405, 378.585600949483, 378.256941184562, 377.92828141964, 377.599621654718, 377.270961889797, 376.942302124875, 376.613642359953, 376.284982595032, 375.95632283011, 375.627663065188, 375.299003300267, 374.970343535345, 374.641683770423, 374.313024005502, 373.98436424058, 373.655704475659, 373.327044710737, 372.998384945815, 372.669725180894, 372.341065415972, 372.01240565105, 371.683745886129, 371.355086121207, 371.026426356285, 370.697766591364, 370.369106826442, 370.04044706152, 369.711787296599, 369.383127531677, 369.054467766756, 368.725808001834, 368.397148236912, 368.068488471991, 367.739828707069, 367.411168942147, 367.082509177226, 366.753849412304, 366.425189647382, 366.096529882461, 365.767870117539, 365.439210352617, 365.110550587696, 364.781890822774, 364.453231057853, 364.124571292931, 363.795911528009, 363.467251763088, 363.138591998166, 362.809932233244, 362.481272468323, 362.152612703401, 361.823952938479, 361.495293173558, 361.166633408636, 360.837973643714, 360.509313878793, 360.180654113871, 359.85199434895, 359.523334584028, 359.194674819106, 358.866015054185, 358.537355289263, 358.208695524341, 357.88003575942, 357.551375994498, 357.222716229576, 356.894056464655, 356.565396699733, 356.236736934811, 355.90807716989, 355.579417404968, 355.250757640047, 354.922097875125, 354.593438110203, 354.264778345282, 353.93611858036, 353.607458815438, 353.278799050517, 352.950139285595, 352.621479520673, 352.292819755752, 351.96415999083, 351.635500225908, 351.306840460987, 350.978180696065, 350.649520931144, 350.320861166222, 349.9922014013, 349.663541636379, 349.334881871457, 349.006222106535, 348.677562341614, 348.348902576692, 348.02024281177, 347.691583046849, 347.362923281927, 347.034263517005, 346.705603752084, 346.376943987162), int1b = c(337.659, 306.187, 354.652, 402.956, 407.314, 268.882, 214.313, 184.202, 261.458, 263.358, 267.363, 321.296, 319.313, 343.466, 341.647, 400.554, 412.553, 283.701, 211.998, 212.104, 231.326, 257.482, 245.777, 264.967, 320.502, 303.002, 395.104, 399.764, 385.096, 293.175, 247.82, 251.4873, 255.1547, 258.822, 253.196, 293.464, 288.594, 317.005, 353.709, 400.507, 411.653, 319.701, 215.766, 179.291, 233.625, 262.575, 270.099, 273.938, 350.146, 284.733, 339.496, 380.202, 389.289, 296.579, 222.609, 211.987, 233.906, 233.018, 257.916, 315.913, 325.348, 322.674, 374.251, 389.016, 403.457, 306.099, 218.053, 203.73, 257.924, 249.709, 280.331, 293.715, 317.27, 327.583, 342.248, 387.11, 390.112, 294.167, 192.596, 199.555, 218.21, 235.872, 271.597, 268.481, 287.481, 318.246, 344.973, 356.371, 400.786, 289.023, 218.471, 237.236, 232.138, 228.698, 254.926, 282.995, 276.488, 301.831, 328.701, 403.065, 390.061, 283.253, 215.397, 228.977, 264.741, 243.561, 247.263, 275.729, 321.688, 328.068, 335.779, 436.347, 372.3, 279.982, 209.529, 187.79, 254.174, 220.566, 237.112, 254.335), xm1b = c(318.723165554443, 325.245047888951, 354.226273334072, 406.565080739617, 398.786417724534, 302.540575824105, 219.637554335367, 219.818468057928, 248.352016555739, 254.538305207261, 263.290302165277, 293.547010122773, 317.20068189685, 323.722564231357, 352.703789676478, 405.042597082023, 397.26393406694, 301.018092166511, 218.115070677774, 218.295984400334, 246.829532898145, 253.015821549668, 261.767818507683, 292.02452646518, 315.678198239256, 322.200080573763, 351.181306018884, 403.520113424429, 395.741450409347, 299.495608508917, 216.59258702018, 216.77350074274, 245.307049240551, 251.493337892074, 260.245334850089, 290.502042807586, 314.155714581662, 320.67759691617, 349.658822361291, 401.997629766835, 394.218966751753, 297.973124851323, 215.070103362586, 215.251017085146, 243.784565582957, 249.97085423448, 258.722851192495, 288.979559149992, 312.633230924068, 319.155113258576, 348.136338703697, 400.475146109242, 392.696483094159, 296.45064119373, 213.547619704992, 213.728533427552, 242.262081925363, 248.448370576886, 257.200367534901, 287.457075492398, 311.110747266474, 317.632629600982, 346.613855046103, 398.952662451648, 391.173999436565, 294.928157536136, 212.025136047398, 212.206049769958, 240.739598267769, 246.925886919292, 255.677883877308, 285.934591834804, 309.58826360888, 316.110145943388, 345.091371388509, 397.430178794054, 389.651515778971, 293.405673878542, 210.502652389804, 210.683566112364, 239.217114610176, 245.403403261699, 254.155400219714, 284.41210817721, 308.065779951286, 314.587662285794, 343.568887730915, 395.90769513646, 388.129032121377, 291.883190220949, 208.980168732211, 209.16108245477, 237.694630952582, 243.880919604105, 252.63291656212, 282.889624519616, 306.543296293693, 313.065178628201, 342.046404073322, 394.385211478866, 386.606548463784, 290.360706563354, 207.457685074616, 207.638598797177, 236.172147294988, 242.358435946511, 251.110432904526, 281.367140862022, 305.020812636099, 311.542694970607, 340.523920415728, 392.862727821272, 385.08406480619, 288.838222905762, 205.935201417023, 206.116115139583, 234.649663637394, 240.835952288916, 249.587949246932, 279.844657204428), xm21b = c(301.136989802236, 301.010116164103, 300.883242525971, 300.756368887838, 300.629495249705, 300.502621611572, 300.375747973439, 300.248874335306, 300.122000697174, 299.995127059041, 299.868253420908, 299.741379782775, 299.614506144642, 299.487632506509, 299.360758868377, 299.233885230244, 299.107011592111, 298.980137953978, 298.853264315845, 298.726390677713, 298.59951703958, 298.472643401447, 298.345769763314, 298.218896125181, 298.092022487048, 297.965148848916, 297.838275210783, 297.71140157265, 297.584527934517, 297.457654296384, 297.330780658252, 297.203907020119, 297.077033381986, 296.950159743853, 296.82328610572, 296.696412467587, 296.569538829455, 296.442665191322, 296.315791553189, 296.188917915056, 296.062044276923, 295.935170638791, 295.808297000658, 295.681423362525, 295.554549724392, 295.427676086259, 295.300802448126, 295.173928809994, 295.047055171861, 294.920181533728, 294.793307895595, 294.666434257462, 294.53956061933, 294.412686981197, 294.285813343064, 294.158939704931, 294.032066066798, 293.905192428665, 293.778318790533, 293.6514451524, 293.524571514267, 293.397697876134, 293.270824238001, 293.143950599869, 293.017076961736, 292.890203323603, 292.76332968547, 292.636456047337, 292.509582409204, 292.382708771072, 292.255835132939, 292.128961494806, 292.002087856673, 291.87521421854, 291.748340580408, 291.621466942275, 291.494593304142, 291.367719666009, 291.240846027876, 291.113972389743, 290.987098751611, 290.860225113478, 290.733351475345, 290.606477837212, 290.479604199079, 290.352730560946, 290.225856922814, 290.098983284681, 289.972109646548, 289.845236008415, 289.718362370282, 289.59148873215, 289.464615094017, 289.337741455884, 289.210867817751, 289.083994179618, 288.957120541485, 288.830246903353, 288.70337326522, 288.576499627087, 288.449625988954, 288.322752350821, 288.195878712689, 288.069005074556, 287.942131436423, 287.81525779829, 287.688384160157, 287.561510522024, 287.434636883892, 287.307763245759, 287.180889607626, 287.054015969493, 286.92714233136, 286.800268693228, 286.673395055095, 286.546521416962, 286.419647778829, 286.292774140696, 286.165900502563, 286.039026864431), int1c = c(330.12, 318.431, 327.077, 350.067, 354.635, 286.192, 190.083, 184.132, 217.212, 243.822, 279.004, 297.32, 297.793, 299.878, 325.734, 339.926, 342.075, 302.869, 181.012, 190.379, 210.625, 249.501, 230.168, 254.838, 261.007, 270.08, 299.933, 338.097, 362.052, 276.066, 227.911, 230.6377, 233.3643, 236.091, 248.358, 270.015, 271.676, 277.334, 293.694, 337.941, 342.579, 273.003, 184.625, 173.348, 235.458, 270.02, 250.739, 266.805, 252.88, 289.514, 312.253, 323.395, 329.9, 298.041, 202.109, 170.806, 212.577, 239.436, 242.506, 269.311, 303.552, 261.419, 300.931, 306.533, 334.002, 270.606, 177.569, 193.139, 251.013, 235.17, 272.396, 259.512, 258.783, 276.894, 284.924, 326.942, 311.817, 246.129, 181.789, 180.655, 214.017, 230.648, 250.46, 255.597, 264.214, 297.154, 286.398, 313.817, 316.461, 255.983, 197.925, 205.333, 222.321, 228.981, 256.776, 256.061, 272.758, 276.704, 314.191, 304.518, 289.288, 264.386, 190.633, 191.457, 225.684, 228.816, 232.328, 272.229, 281.356, 288.42, 293.75, 332.596, 300.352, 255.305, 188.216, 178.514, 209.626, 209.042, 246.778, 242.794 ), xm1c = c(290.06352814967, 299.382850823025, 316.255118181764, 339.05025946068, 342.660177561356, 283.232990707666, 206.791746908856, 201.055983316997, 236.077286876763, 250.501604679341, 261.86139749717, 279.089173432355, 287.27074263864, 296.590065311994, 313.462332670733, 336.25747394965, 339.867392050326, 280.440205196636, 203.998961397826, 198.263197805966, 233.284501365732, 247.708819168311, 259.06861198614, 276.296387921325, 284.477957127609, 293.797279800964, 310.669547159703, 333.464688438619, 337.074606539296, 277.647419685605, 201.206175886795, 195.470412294936, 230.491715854702, 244.91603365728, 256.275826475109, 273.503602410294, 281.685171616579, 291.004494289933, 307.876761648672, 330.671902927589, 334.281821028265, 274.854634174575, 198.413390375765, 192.677626783905, 227.698930343671, 242.12324814625, 253.483040964079, 270.710816899264, 278.892386105548, 288.211708778903, 305.083976137642, 327.879117416558, 331.489035517235, 272.061848663544, 195.620604864734, 189.884841272875, 224.906144832641, 239.330462635219, 250.690255453048, 267.918031388233, 276.099600594518, 285.418923267872, 302.291190626611, 325.086331905528, 328.696250006204, 269.269063152514, 192.827819353704, 187.092055761845, 222.11335932161, 236.537677124189, 247.897469942018, 265.125245877203, 273.306815083487, 282.626137756842, 299.498405115581, 322.293546394497, 325.903464495174, 266.476277641483, 190.035033842673, 184.299270250814, 219.32057381058, 233.744891613159, 245.104684430987, 262.332460366172, 270.514029572457, 279.833352245811, 296.705619604551, 319.500760883467, 323.110678984143, 263.683492130453, 187.242248331643, 181.506484739784, 216.527788299549, 230.952106102128, 242.311898919957, 259.539674855142, 267.721244061427, 277.040566734781, 293.91283409352, 316.707975372436, 320.317893473113, 260.890706619422, 184.449462820612, 178.713699228753, 213.735002788519, 228.159320591097, 239.519113408926, 256.746889344111, 264.928458550396, 274.247781223751, 291.12004858249, 313.915189861406, 317.525107962083, 258.097921108393, 181.656677309581, 175.920913717722, 210.942217277488, 225.366535080067, 236.726327897896, 253.954103833081), xm21c = c(276.781869825526, 276.549137699607, 276.316405573687, 276.083673447768, 275.850941321849, 275.61820919593, 275.385477070011, 275.152744944091, 274.920012818172, 274.687280692253, 274.454548566334, 274.221816440415, 273.989084314495, 273.756352188576, 273.523620062657, 273.290887936738, 273.058155810819, 272.825423684899, 272.59269155898, 272.359959433061, 272.127227307142, 271.894495181223, 271.661763055303, 271.429030929384, 271.196298803465, 270.963566677546, 270.730834551627, 270.498102425707, 270.265370299788, 270.032638173869, 269.79990604795, 269.567173922031, 269.334441796111, 269.101709670192, 268.868977544273, 268.636245418354, 268.403513292434, 268.170781166515, 267.938049040596, 267.705316914677, 267.472584788758, 267.239852662838, 267.007120536919, 266.774388411, 266.541656285081, 266.308924159162, 266.076192033242, 265.843459907323, 265.610727781404, 265.377995655485, 265.145263529566, 264.912531403646, 264.679799277727, 264.447067151808, 264.214335025889, 263.98160289997, 263.74887077405, 263.516138648131, 263.283406522212, 263.050674396293, 262.817942270374, 262.585210144454, 262.352478018535, 262.119745892616, 261.887013766697, 261.654281640778, 261.421549514858, 261.188817388939, 260.95608526302, 260.723353137101, 260.490621011182, 260.257888885262, 260.025156759343, 259.792424633424, 259.559692507505, 259.326960381585, 259.094228255666, 258.861496129747, 258.628764003828, 258.396031877909, 258.163299751989, 257.93056762607, 257.697835500151, 257.465103374232, 257.232371248313, 256.999639122393, 256.766906996474, 256.534174870555, 256.301442744636, 256.068710618717, 255.835978492797, 255.603246366878, 255.370514240959, 255.13778211504, 254.905049989121, 254.672317863201, 254.439585737282, 254.206853611363, 253.974121485444, 253.741389359525, 253.508657233605, 253.275925107686, 253.043192981767, 252.810460855848, 252.577728729929, 252.344996604009, 252.11226447809, 251.879532352171, 251.646800226252, 251.414068100333, 251.181335974413, 250.948603848494, 250.715871722575, 250.483139596656, 250.250407470736, 250.017675344817, 249.784943218898, 249.552211092979, 249.31947896706, 249.08674684114)), .Names = c("xs", "int1a", "xm1a", "xm21a", "int1b", "xm1b", "xm21b", "int1c", "xm1c", "xm21c" ), row.names = c(NA, -120L), class = "data.frame")