R - Изменить метку легенды - PullRequest
0 голосов
/ 28 мая 2020

Я хочу изменить метку легенды: вместо цветного шестнадцатеричного кода поставить «скорость», «температура» и «давление».

  ggplot(f1, aes(timestamp)) +
  geom_point(aes(y=speed, color="#e41a1c")) +
  geom_point(aes(y=pressure, color="#377eb8")) +
  geom_point(aes(y=temperature, color="#4daf4a"))

Result plot

1 Ответ

0 голосов
/ 28 мая 2020

вы можете попробовать это:

ggplot(f1, aes(timestamp)) +
geom_point(aes(y=speed, color="speed")) +
  geom_point(aes(y=pressure, color="pressure")) +
  geom_point(aes(y=temperature, color="temperature"))

чтобы настроить цвета, вы можете сделать это:

ggplot(f1, aes(timestamp)) +
geom_point(aes(y=speed, color="speed")) +
  geom_point(aes(y=pressure, color="pressure")) +
  geom_point(aes(y=temperature, color="temperature"))+
  scale_color_manual("variable", values=c("red", "yellow", "blue")) #or your hex-codes
...