I have a data frame that consists of three (3) variables (Methods, lb and RMSE).
df1 <- data.frame(Methods = c('b', 'a', 'c', 'd', 'e'), lb = c(9, 7, 9, 4, 9), RMSE = c(0.26177952, 0.11294586, 0.02452239, 0.08290467, 0.41488542))
df1
Methods lb RMSE
1 b 9 0.26177952
2 a 7 0.11294586
3 c 9 0.02452239
4 d 4 0.08290467
5 e 9 0.41488542
I want the Methods(a, b, c, d, e) to be arranged on the x-axis, the height of the lollypop plot
to correspond to the values of RMSE while the colours on the lillyplot
to vary among the lb
variable.
I have tried this
df1 |>
ggplot2::ggplot(ggplot2::aes(x = Methods, y = RMSE)) + ggplot2::geom_point(size = 4) +
ggplot2::geom_segment(ggplot2::aes(x = Methods, xend = Methods, yend = RMSE, y = 0)) +
ggplot2::scale_fill_manual(values = c("green", "yellowgreen", "yellow", "orange", "red"))
df1 |>
ggplot2::ggplot(ggplot2::aes(x = Methods, y = RMSE)) + ggplot2::geom_point(size = 4) +
ggplot2::geom_segment(ggplot2::aes(x = Methods, xend = Methods, yend = RMSE, y = 0)) +
ggplot2::scale_fill_manual(values = c("green", "yellowgreen", "yellow", "orange", "red")) +
ggplot2::theme_bw() + ggplot2::scale_colour_gradientn(colours = rev(rainbow(5)))
When I changed from manual
the image is still the same without colour.
What I want
I want the pop with colours such that I can customize the pop's colours