I am trying to generate population plot using code below. I re used some of code I found. However, I dont know I can optimise legends according to the data range I have. I mean