I want to change the size, linetype, color etc. for one line in ggplot.
Here is a minimal reproducible example:
library
Following this duplicate here is another answer to this question.
It uses a simple trick, to tell the highlighted variable by comparing it with the target value. This dichotomyzes it, becoming a logical FALSE/TRUE value.
variable == "Country1"
The plot legend now needs more care to be taken, in order to have its title and text right.
g <- ggplot(df_long, aes(x = Horizons, y = value)) +
geom_line(aes(colour = variable == "Country1", size = variable == "Country1", group = variable)) +
scale_color_manual(name = "variable", labels = c("Other", "Country1"), values = c("grey50", "red")) +
scale_size_manual(name = "variable", labels = c("Other", "Country1"), values = c(0.5, 2)) +
theme_bw()
g