Change the color inside the plot

Viewed 56

In this plot

library(ggplot2)

df <- data.frame(year = c(2011,2012,2013,2014,2015,2016,2017,2018), 
                 value = c(337,423,551,661,846,1387,2222,3580))

ggplot(df, aes(year, value)) +
  geom_point() +
  geom_line() +
  geom_text(aes(label = value, y = (value - 50)*0.9))

How is it possible to make the color of numbers of value red?

1 Answers

Like this?

library(ggplot2)

df <- data.frame(year = c(2011,2012,2013,2014,2015,2016,2017,2018), 
                 value = c(337,423,551,661,846,1387,2222,3580))

ggplot(df, aes(year, value)) +
  geom_point() +
  geom_line() +
  geom_text(aes(label = value, y = (value - 50)*0.9), color = "red")

example.png

Or like this?

library(ggplot2)

df <- data.frame(year = c(2011,2012,2013,2014,2015,2016,2017,2018), 
                 value = c(337,423,551,661,846,1387,2222,3580))

ggplot(df, aes(year, value)) +
  geom_point() +
  geom_line() +
  geom_text(aes(label = value, y = (value - 50)*0.9), color = "red") +
  theme(axis.text.y = element_text(colour = "red"))

example_2.png

Related