I would like to make a box with a colour gradient (discrete or continuous) as shown in the picture below with ggplot2 in R. The colour in the box shows how close points are fitted, i.e. values are given in a simple vector. The box should appear right below my plot.
Can anybody give a hint how such a box can be built?
Asked
Active
Viewed 95 times
0

N8_Coder
- 713
- 3
- 10
- 20
-
1have a look at [this question here](https://stackoverflow.com/questions/50506832/create-discrete-color-bar-with-varying-interval-widths-and-no-spacing-between-le/50518287#50518287) It might contain what you want. Basically, it is about using `geom_rect` – tjebo Aug 08 '18 at 07:36
-
1This can be useful too https://github.com/tidyverse/ggplot2/issues/2673#issuecomment-402878574 – Tung Aug 09 '18 at 01:41