I want to create a graph in R similar to the one below to show which place belongs to a particular person or company compared to my peers. The score will always be from 1 to 100.

Although I succumb to any ggplot solution, it seemed to me that the best way is to use geom_rect , and then adapt and add the arrow described in the baptiste answer to this question . However, I found fault with something even simpler - getting geom_rect in order to fill the gradient correctly, as shown in the manual to the right of the graph below. It should be easy. What am I doing wrong?
library(ggplot2) library(scales) mydf <- data.frame(id = rep(1, 100), sales = 1:100) ggplot(mydf) + geom_rect(aes(xmin = 1, xmax = 1.5, ymin = 0, ymax = 100, fill = sales)) + scale_x_discrete(breaks = 0:2, labels = 0:2) + scale_fill_gradient2(low = 'blue', mid = 'white', high = 'red', midpoint = 50) + theme_minimal()

r ggplot2
Slowlowearner
source share