Create different curves on a same graph, with different colors

Hello,

I created one graph (see attached) for one area forest loss,

Try to put a reproducible example of data for get a better help for all community.

See this:

Other way is paste the result of:

dput(head(Azagny ,50))

Finally, you could draw the plot that you want for better understand.

Hello,

Ok, thank you for your answer.

Im make a filter of 4 nm_pa

Preformatted  <- structure(list(id_pr = c("CBJ1127", "CCM1171", "CZZ1260", "CCI1369",
"CCI1369", "CCI1369", "CCI1369", "CCI1369", "CCI1369", "CCI1369",
"CCI1369", "CCI1369", "CCI1369", "CCI1369", "CCI1369", "CCI1369",
"CCI1369", "CCI1369", "CCI1369", "CCI1369", "CCI1369", "CCI1369",
"CCI1369", "CCI1369", "CKE1036", "CKE1010", "CMR1164", "CMR1164",
"CMR1164", "CMR1164", "CMR1164", "CMR1164", "CMR1164", "CMR1164",
"CMR1164", "CMR1164", "CMR1164", "CMR1164", "CMR1164", "CMR1164",
"CMR1164", "CMR1164", "CMR1164", "CMR1164", "CMR1164", "CMR1164",
"CMR1164", "CZZ1382", "CZZ1382", "CZZ1382"), nm_ap = c("Parc National de la Pendjari",
"Bouba Ndjida National Park", "Odzala Kokoua", "Mont Peko National Park",
"Mont Peko National Park", "Mont Peko National Park", "Mont Peko National Park",
"Mont Peko National Park", "Mont Peko National Park", "Mont Peko National Park",
"Mont Peko National Park", "Mont Peko National Park", "Mont Peko National Park",
"Mont Peko National Park", "Mont Peko National Park", "Mont Peko National Park",
"Mont Peko National Park", "Mont Peko National Park", "Mont Peko National Park",
"Mont Peko National Park", "Mont Peko National Park", "Mont Peko National Park",
"Mont Peko National Park", "Mont Peko National Park", "Marsabit National reserve",
"Meru", "banc d'arguin", "banc d'arguin", "banc d'arguin", "banc d'arguin",
"banc d'arguin", "banc d'arguin", "banc d'arguin", "banc d'arguin",
"banc d'arguin", "banc d'arguin", "banc d'arguin", "banc d'arguin",
"banc d'arguin", "banc d'arguin", "banc d'arguin", "banc d'arguin",
"banc d'arguin", "banc d'arguin", "banc d'arguin", "banc d'arguin",
"banc d'arguin", "Casamance", "Casamance", "Casamance"), wdpaid = c("597",
"606", "643", "724", "724", "724", "724", "724", "724", "724",
"724", "724", "724", "724", "724", "724", "724", "724", "724",
"724", "724", "724", "724", "724", "753", "755", "797", "797",
"797", "797", "797", "797", "797", "797", "797", "797", "797",
"797", "797", "797", "797", "797", "797", "797", "797", "797",
"797", "869", "869", "869"), ann_c = c(2000, 2004, 2002, 2013,
2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013,
2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2011, 2001,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012,
2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2012, 2008,
2008, 2008), years = c(NA, NA, NA, 2000L, 2001L, 2002L, 2003L,
2004L, 2005L, 2006L, 2007L, 2008L, 2009L, 2010L, 2011L, 2012L,
2013L, 2014L, 2015L, 2016L, 2017L, 2018L, 2019L, 2020L, NA, NA,
2000L, 2001L, 2002L, 2003L, 2004L, 2005L, 2006L, 2007L, 2008L,
2009L, 2010L, 2011L, 2012L, 2013L, 2014L, 2015L, 2016L, 2017L,
2018L, 2019L, 2020L, 2000L, 2001L, 2002L), treecover = c(NA,
NA, NA, 30437.7006315165, 29935.3994516042, 29838.6380553894,
29699.4827246049, 29550.2417984714, 29466.2362672127, 29298.4374817644,
29156.4552691228, 28854.0882606882, 28427.0782339354, 27619.6266947924,
26893.2846040161, 24961.6357356898, 24079.4363257385, 23225.8474343037,
22893.6372669039, 22695.4532354499, 22326.4761037899, 21307.4063880757,
21086.4709603277, 20060.1267311011, NA, NA, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)), row.names = c(NA,
-50L), class = c("tbl_df", "tbl", "data.frame"))

library(tidyverse)
Preformatted |> 
  filter(nm_ap %in% c('Mont Peko National Park',"banc d'arguin",
                      'Marsabit National reserve','Casamance')) |> # filter 4 nm_ap
  ggplot(aes(x=years,y=treecover, fill=nm_ap, color=nm_ap))+
  scale_color_manual(values=c('green','blue','red','orange'))+
  geom_line()+
  geom_vline(xintercept = 2003, color = "blue")+
  geom_vline(xintercept = 2005, color = "black")+
  geom_vline(xintercept = 2010, color = "green")+
  geom_vline(xintercept = 2014.2, color = "orange") # in this way you could add other vertical lines

Great, thank you very much.

Have a good evening
regards

You could filter a single area if add this :

Preformatted |> 
filter(nm_ap == 'Mont Peko National Park')

Please for better understand you could draw an example of the plot that you want.

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.