I want to plot linetypes manually according to weather it is a country (objects of analysis) or a group of countries for comparison. I also renamed the observations from the country code to the name of the country for presentation reasons. That last part has worked so far, but I can't seem to know if it is causing the problem.
I have written this code:
data_pop_growth_rate_output_worker %>% filter(ref_area == "CHN" |
ref_area == "PRK" |
ref_area == "VNM" |
ref_area == "X05") %>%
mutate(ref_area = recode(ref_area,
CHN = "China",
PRK = "Coreia",
VNM = "Vietnã",
X05 = "Mundo: alta renda")) %>%
ggplot()+
geom_line(aes(x = time,
y = obs_value,
colour = ref_area))+
scale_color_manual(values = c("China" = "#FE6100",
"Coreia" = "#648FFF",
"Vietnã" = "#FFB000",
"Mundo: alta renda" = "#785EF0"
))+
scale_linetype_manual(values = c("China" = "solid",
"Coreia" = "solid",
"Vietnã" = "solid",
"Mundo: alta renda" = "dotted"
))
The result is:
I manual scalling of linetype doesn't seem to work. The world ("mundo") area stays solid.
Tried to manually plot a dotted line type for one specific observation.
Uncertain without data, but you need to add aes(linetype=ref_area)
. Perhaps
ggplot()+
geom_line(aes(x = time,
y = obs_value,
colour = ref_area,
linetype = ref_area)) + ## add this
scale_color_manual(values = c("China" = "#FE6100",
"Coreia" = "#648FFF",
"Vietnã" = "#FFB000",
"Mundo: alta renda" = "#785EF0"
))+
scale_linetype_manual(values = c("China" = "solid",
"Coreia" = "solid",
"Vietnã" = "solid",
"Mundo: alta renda" = "dotted"
))