A bit difficult without some reproducible data, but you should be able to achieve this by adding a geom_line()
that only uses the data for that specific country:
ggplot(data3, aes(year, NY.GDP.MKTP.KD.ZG, color = country)) + geom_line() +
xlab('Year') + ylab('GDP per capita') +
labs(title = "Annual GDP Growth rate (%)") +
theme_bw() +
geom_line(data=subset(data3, country == "China"), colour="black", size=1.5)
Keeping the legend in line with the colour and size is a bit trickier- you can do it by manually hacking at the legend with override.aes
, but it's not necessarily the most elegant solution:
# Needed to access hue_pal(), which is where ggplot's
# default colours come from
library(scales)
ggplot(data3, aes(year, NY.GDP.MKTP.KD.ZG, color = country)) + geom_line() +
xlab('Year') + ylab('GDP per capita') +
labs(title = "Annual GDP Growth rate (%)") +
theme_bw() +
geom_line(data=subset(data3, country == "World"), colour="black", size=1.5) +
guides(colour=guide_legend(override.aes=list(
colour=c(hue_pal()(11)[1:10], "black"), size=c(rep(1, 10), 1.5))))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…