-
Метод 1: использование функции
labs()library(ggplot2) ggplot(data, aes(x = x, y = y, color = category)) + geom_point() + labs(color = "Legend Title") -
Метод 2: изменение функции
guide_legend()library(ggplot2) ggplot(data, aes(x = x, y = y, color = category)) + geom_point() + guides(color = guide_legend(title = "Legend Title")) -
Метод 3: использование функции
scale_color_*()library(ggplot2) ggplot(data, aes(x = x, y = y, color = category)) + geom_point() + scale_color_discrete(name = "Legend Title") -
Метод 4. Изменение функции
theme()library(ggplot2) ggplot(data, aes(x = x, y = y, color = category)) + geom_point() + theme(legend.title = element_text(text = "Legend Title"))